Timeline for Sending Large Packets and Reassembling over Serial
Current License: CC BY-SA 3.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 13, 2017 at 12:50 | history | edited | CommunityBot |
replaced http://arduino.stackexchange.com/ with https://arduino.stackexchange.com/
|
|
Sep 30, 2016 at 22:33 | answer | added | Nick Gammon♦ | timeline score: 2 | |
Sep 30, 2016 at 22:32 | history | edited | Nick Gammon♦ |
edited tags
|
|
Sep 30, 2016 at 22:23 | comment | added | Nick Gammon♦ | Can you please clarify where you are sending the data to? Are you sending it to the same device? Why? You already have it there. | |
Sep 30, 2016 at 14:24 | answer | added | Majenko | timeline score: 2 | |
Sep 30, 2016 at 10:09 | comment | added | Majenko | The heart of your problem is that you are writing 30000 bytes then reading 30000 bytes instead of reading 30000 bytes whilst writing 30000 bytes. You have to do both at once. | |
Sep 30, 2016 at 10:04 | comment | added | Andrew |
If the existing buffer handles the rx_buf_full interrupt (which it does not if you read HardwareSerial.h and UARTClass.cpp), it simply sets up a ring buffer. If you think that this is actually how the Serial class already works, then please explain how the code I provided does not read from the buffer fast enough at 115200 and that the read does not come at the right time.
|
|
Sep 30, 2016 at 9:12 | comment | added | Majenko | The existing buffer does that job. It is up to you to then read from that buffer fast enough and at the right time. | |
Sep 30, 2016 at 9:10 | comment | added | Andrew | Please refer to chapter 34 of the SAM3X8E datasheet to understand how the Serial characteristics work on this particular chipset. | |
Sep 30, 2016 at 9:08 | comment | added | Andrew |
I have done that, and lost a few marbles in the process. But it indeed does require a rewrite of stream . If you want to read any amount of continuous data that is larger than your buffer size, you need to include the specific uart driver for the chip and use the interrupt routine uart_is_rx_buf_full . In fact, this is how readBytes() should work in the first place, but it is mainly written for AVR chips.
|
|
Sep 29, 2016 at 22:58 | comment | added | Majenko | No, it requires a rewriting of your understanding of serial communications. | |
Sep 29, 2016 at 20:57 | comment | added | Andrew |
Yes, clearly the Arduino code does not handle this contingency properly as I would have hoped. It requires a rewrite of the stream function read() .
|
|
Sep 29, 2016 at 14:20 | comment | added | Majenko | Imagine you have a bucket with 30,000 marbles in it, and two cups that can hold 256 marbles each. You want to empty the bucket of marbles and then put all the marbles back in again. How do you do it without getting marbles all over the floor? | |
Sep 29, 2016 at 14:07 | comment | added | Majenko | You write 30,000 bytes of data out of a serial port, then read that data as it appears on the UART pins into a 256 byte buffer. Once you have sent all 30,000 bytes into that 256 byte buffer you then try and read 30,000 bytes out of that 256 byte buffer and wonder why it doesn't work right...? | |
Sep 29, 2016 at 14:06 | comment | added | Majenko | I think you have a fundamental lack of understanding about how serial communications works. | |
Sep 29, 2016 at 9:27 | history | asked | Andrew | CC BY-SA 3.0 |