I am currently using my arduino MegaADK to receive data from matlab (via usb), and then send it out to another location (using PORTs, not serial). I can also read data back form this location, and then send it to matlab. In order to send data, I send a specific 6 byte command from matlab followed by the data, and in order to read it back I send a different command. What I would like to be able to do is send this command at any time (even if the arduino is currently sending data) and store it in a buffer. Then, once the arduino has completed its current task, it will read the command I sent and act accordingly.
I have looked into using serialEvent but I want it to read the serial data even if I am in the middle of the loop. Is there any way is setting up a USB Serial driven interrupt ervice routine that will just read the data and store it?
I have looked into using serialEvent but I want it to read the serial data even if I am in the middle of the loop. Is there any way is setting up a USB Serial driven interrupt ervice routine that will just read the data and store it?
There is already an interrupt handler that handles the arrival of serial data. That interrupt handler saves the data in a buffer that Serial(N).available() and Serial(N).read() access. Why is that not sufficient?
Oh ok, that will be sufficient. The command will be a 6 byte array, will I be able to use Serial.readBytes on this as well? I don't know how large the buffer is, I just don't want to lose the command.
Thanks a lot!