Pointer headaches - Casting a &struct to a byte * [solved]
i trying stuff struct through serial line. in theory, should work - send bytes containing structure stream of bytes, , on other end stream gets put similar struct. it should work. if compiler let me.
on sending end:
on receiving end:
the sendmsg , recvmsg functions work. i've tested them. sends correct number of bytes. but structure on receiving end remains unchanged. the data that's transferred never placed in it. so memory location hosed.
the sendmsg , recvmsg functions nick gammon's rs485 lib, , can trusted work if given correct pointers. the pointers typecast (byte *).
if use buffer , memcpy stuff works fine. want avoid assigning buffer if can short of ram already.
i doing wrong pointers. but what?
on sending end:
code: [select]
sendmsg (fwrite, (byte *) (&somestruct), sizeof somestruct);
on receiving end:
code: [select]
recvmsg (favailable, fread, (byte *) (&somestruct), sizeof somestruct, 1000);
the sendmsg , recvmsg functions work. i've tested them. sends correct number of bytes. but structure on receiving end remains unchanged. the data that's transferred never placed in it. so memory location hosed.
the sendmsg , recvmsg functions nick gammon's rs485 lib, , can trusted work if given correct pointers. the pointers typecast (byte *).
if use buffer , memcpy stuff works fine. want avoid assigning buffer if can short of ram already.
i doing wrong pointers. but what?
won't let me delete. pointers ok; code falling through on case statement....
Arduino Forum > Using Arduino > Programming Questions > Pointer headaches - Casting a &struct to a byte * [solved]
arduino
Comments
Post a Comment