ArduinoFake icon indicating copy to clipboard operation
ArduinoFake copied to clipboard

Any intention to support an EEPROM 'fake'

Open david284 opened this issue 2 years ago • 6 comments

One of the libraries I'm using expects 'EEPROM.h' Is there any intention to support a version of this in ArduinoFake?

david284 avatar Feb 14 '23 11:02 david284

Hi,

I'm not planing on working on it, But I think it should be supported.

But there are instructions here explaining how to make a PR adding support : https://github.com/FabioBatSilva/ArduinoFake/blob/master/CONTRIBUTING.md

It will looks something like this: https://github.com/FabioBatSilva/ArduinoFake/pull/26/files

FabioBatSilva avatar Feb 16 '23 19:02 FabioBatSilva

Wow what a coincidence! I just dug up a project I abandoned 3 years ago and now remembering it was because I did not understand how to write a test for a file that uses <EEPROM.h>. I thought surely there's a way and have burned up a couple horus here still not finding a solution.

@FabioBatSilva when you say "i think it should be supported" do you mean that you think it already should work, or are you suggesting that we should try to add it ourselves?

wraybowling avatar Mar 07 '23 00:03 wraybowling

@wraybowling I mean something we should support.

Yes, something that you or someone else interested can contribute following the example/doc i linked.

FabioBatSilva avatar Mar 07 '23 01:03 FabioBatSilva

I started playing with making ArduinoFake support EEPROM but quickly realized that the biggest problem is going to be the use of templates. Since you can't use templates and virtual methods, there's really no way to support the ability to read and write arbitrary datatypes.

@david284 How does the library you're using interact with EEPROM.h?

@FabioBatSilva If you think it's worth it to have a partially supported EEPROM, I can send a PR for my limited functionality one. It would at least be a start in case someone wanted to add more functionality (like array access, which I didn't implement) but I kinda hate adding something that's "broken"

wrong-kendall avatar May 17 '23 23:05 wrong-kendall

The library is using byte orientated read/writes I believe

  byte readEEPROM(unsignedinteeaddress); voidwriteEEPROM(unsignedinteeaddress, byte data);   byte readBytesEEPROM(unsignedinteeaddress, byte nbytes, byte dest[]); voidwriteBytesEEPROM(unsignedinteeaddress, byte src[], byte numbytes);

If that's what you're asking

Regards David

On 18/05/2023 00:07, wrong-kendall wrote:

I started playing with making ArduinoFake support EEPROM https://github.com/wrong-kendall/ArduinoFake/commit/16f286a954a32114a2682876c5366c69dbbee63c but quickly realized that the biggest problem is going to be the use of templates. Since you can't use templates and virtual methods, there's really no way to support the ability to read and write arbitrary datatypes.

@david284 https://github.com/david284 How does the library you're using interact with |EEPROM.h|?

@FabioBatSilva https://github.com/FabioBatSilva If you think it's worth it to have a partially supported EEPROM, I can send a PR for my limited functionality one. It would at least be a start in case someone wanted to add more functionality (like array access, which I didn't implement) but I kinda hate adding something that's "broken"

— Reply to this email directly, view it on GitHub https://github.com/FabioBatSilva/ArduinoFake/issues/40#issuecomment-1552196890, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANUGDYIZZP2ELWH4Q2WRWFTXGVK37ANCNFSM6AAAAAAU3OVMLE. You are receiving this because you were mentioned.Message ID: @.***>

david284 avatar May 18 '23 11:05 david284

Thanks, that's exactly what I was asking and that's the only functionality that my change implements.

wrong-kendall avatar May 19 '23 20:05 wrong-kendall