SimpleModbusSlave.h adding an ISR for direct "realtime" response

Hello guys,

I'm currently writing a program that collects sensor data, processes it and put it out on RS-232 and RS-485. I'm using the SimpleModbusSlave.h library and as far to now everything runs pretty smooth, the data is processed and when i click on "poll" in CAS Modbus Scanner a Response mostly comes in.. After a little while. And this is just what's annoying me, the time to wait on a response. It just sends at a given time in the loop. I want to program it like : I press "Poll" and an ISR on USART2 RECEIVE comes on and puts the data directly out. A test-ISR with an example string works, but i dont know what to write in the ISR to send the packet.
I tried it with "sendPacket" and with "modbus_update()".
Does anyone know what i mean and can help me?

Best regards,

shaun

I'm using the SimpleModbusSlave~~.h~~ library

I want to program it like : I press "Poll" and an ISR on USART2 RECEIVE comes on

Receiving serial data is already interrupt driven. Hooking more code into the interrupt handler is a REALLY bad idea.

YOUR code should be handling data that arrives in the serial buffer in a timely fashion.

Does anyone know what i mean

No, since you failed to post any code.

and can help me?

See above for a hint.

Okok, I did not make myself clear enough :wink:

The only thing I want to know is: What function is called from the SimpleModbusSlave library when my ATmega receives a Modbus-Request? What component sends the Modbus answer? It should be just a String that I will send in the ISR so why would that be such a big Problem?

PaulS:
No, since you failed to post any code.

I don't think there has to be code to answer this question.

What function is called from the SimpleModbusSlave library when my ATmega receives a Modbus-Request?

We would need to see a link to the library.

It should be just a String that I will send in the ISR so why would that be such a big Problem?

The serial data arriving ISR is triggered for EVERY byte that arrives. It puts the data in the incoming serial data buffer.

You would have to modify the hardware serial class to check for a string in the buffer. You would have to modify your sketch and the modbus library to NOT read from the serial port until the hardware serial class told it it was OK to read from the serial buffer.

You would have to modify the hardware serial class to invoke some function in the modbus instance.

You can see, I hope, that YOU are the only one that needs this complex mish-mash of classes, and that it would affect EVERY sketch you write that uses the HardwareSerial class(es).