Pointer headaches - Casting a &struct to a byte * [solved]

I am trying to stuff a struct through a serial line. In theory, this should work - I just send the bytes containing the structure as a stream of bytes, and on the other end the stream gets put into a similar struct. It all should work. If only the compiler would let me.

On the sending end:

sendMsg (fWrite, (byte *) (&someStruct), sizeof someStruct);

On the receiving end:

recvMsg (fAvailable, fRead, (byte *) (&someStruct), sizeof someStruct, 1000);

The sendMsg and recvMsg functions work. I've tested them. It sends the correct number of bytes. But the structure on the receiving end remains unchanged. The data that's transferred is never placed in it. So my memory location is hosed.

The sendMsg and recvMsg functions are from Nick Gammon's rs485 lib, and can be trusted to work if given the correct pointers. The pointers are typecast for (byte *).

If I use a buffer and memcpy stuff it works fine. But I want to avoid assigning another buffer if I can as I am short of ram already.

I am doing something wrong with the pointers. But what?

Won't let me delete. The pointers are OK; the code was falling through on a case statement....

That's why we ask for the whole thing to be posted, not just one line. :slight_smile:

Anyway, glad it's working.