ok. i'm trying read settings sent on .net program made update settings in arduino nano. idea read settings when jumper (or pin) becomes high , store settings in eeprom. function i'm having problems last on in code. deserialize. i'm trying struct out of bytes read serial stream.
i keep getting gibberish when try deserialize.
code: [select]
template <class t> int writevals(int ee, const t& value)
{
const byte* p = (const byte*)(const void*)&value;
unsigned int i;
(i = 0; < sizeof(value); i++)
eeprom.write(ee++, *p++);
return i;
}
template <class t> int readvals(int ee, t& value)
{
byte* p = (byte*)(void*)&value;
unsigned int i;
(i = 0; < sizeof(value); i++)
*p++ = eeprom.read(ee++);
return i;
}
template <class t> int deserialize(const byte buff[], t& value)
{
byte* p = (byte*)(void*)&value;
unsigned int i;
(i = 0; < sizeof(value); i++)
*p++ = buff[i];
return i;
}
i keep getting gibberish when try deserialize.
what trying send? receive (bytes)? , data in .net on pc same data in c/c++ on avr mpu?
cheers!
cheers!
Arduino Forum > Using Arduino > Programming Questions > Serial: Reading a struct sent by a C# program
arduino
Comments
Post a Comment