madleech / ArduinoCMRI

Arduino library for connecting your computer to your model railroad.
27 stars 18 forks source link

Compiling error message in Arduino IDE #5

Closed k4kfh closed 8 years ago

k4kfh commented 8 years ago

When I compile my program, I get this warning message:

/home/hampton/Arduino/libraries/CMRI/CMRI.cpp: In member function 'uint8_t CMRI::_decode(uint8_t)':
/home/hampton/Arduino/libraries/CMRI/CMRI.cpp:240:9: warning: converting to non-pointer type 'uint8_t {aka unsigned char}' from NULL [-Wconversion-null]
  return NULL;
         ^
/home/hampton/Arduino/libraries/CMRI/CMRI.cpp:252:10: warning: converting to non-pointer type 'uint8_t {aka unsigned char}' from NULL [-Wconversion-null]
   return NULL;
          ^

I'm not experienced enough to know what this means, or if I should even worry about it, but I've never seen this error before when using this library.

madleech commented 8 years ago

Thanks, that does look like a bug. It should still work fine with the warning, but I will fix this to make sure it doesn't happen.

k4kfh commented 8 years ago

No problem. I dunno if you want me to make a separate issue, but one feature that would be super useful is a get_bit_change function. I'm DCCing a turntable with your library (excellent work btw) and I need it to act on whenever a bit changes. I know I can write that part of the program myself, just thought maybe it'd be a useful feature in the library.

madleech commented 8 years ago

Ok updated version committed that fixes this and a couple of other compilation warnings.

Firing an event when a bit changes is a great idea, I will have to think about that. Part of the challenge is that you need to track:

Which means 3x bits for every output bit in the protocol, and I don't really want to introduce that kind of overhead. This is where event-based protocols are quite interesting, as when you get an event, you know it is because that bit has changed. I'll have a think though and see if I come up with something cunning.