Pointer variables get changed

Hello Forum,
I'm using the library: LIN_master_Arduino

And I have the problem, that a variable inside this library seems to get changed. Let me explain this:
when I want to receive data with "receiveSlaveResponse", the received data is wrong (but just partly!). I checked it with a LIN-Oscilloscope, for example: The oscilloscope reads:

Checksum 12

When I use the library I get:
Checksum 12

The checksum is correct, so the library doesnt throw an error. Also the received data inside the function LIN_Master::handlerReceive(void) is correct (variable bufRx). After the receive, the rx_handler is called with: (line 654)

// use callback function to handle received data. Only data bytes (- BREAK - SYNC - ID - CHK)
    rx_handler(lenRx-4, bufRx+3);

So far, so good. What's happening now? It seems as rx_handler is a function to which 2 parameters will be given. But the function rx_handler is declared nowhere as in the class itself but with no content.

This is a screenshot of where rx_handler has been found:

Both sets of bytes have the same checksum? That's odd.

"rx_handler" is a pointer to a callback function provided when "receiveSlaveResponse" was called.

Yes, the checksum is the same. The library checks the checksum first (where the data is okay) and then copies the variable. I think this is the reason..

In the main, I have an array Rx[8] which is 8 bytes long and it contains the received message from the slave. And the method receiveSlaveResponse should write the received message to Rx[8] somehow with pointers, but I'm a bloody beginner with pointers, so I don't understand what is going on there.

Could you explain it to me a little more in detail? Thank you, I very appreciate your help!

It's hard to explain code I can't see. Perhaps you can show your sketch that uses the library you pointed to. It seems most likely that the problem is in your code and not in the library.

Or are you using a library example unchanged? If so, which one?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.