Hot answers tagged

4

There is more to low-latency communication than just squirting data as fast as you can (though that is an important part of it). One thing people often forget is that the Arduino can only (easily) do one thing at a time. While you're sending your buffer to the PC it can't be sampling and filling your buffer. If you have a buffer which fills up over the ...


2

It is an internal buffer and only the pointer gets increased. It it visible in the source code off the project, located on github: // Read data from buffer int SoftwareSerial::read() { if (!isListening()) return -1; // Empty buffer? if (_receive_buffer_head == _receive_buffer_tail) return -1; // Read from "head" uint8_t d = ...


2

You can do it with snprintf_P: char mac[18]; snprintf_P(mac, 18, (PGM_P)F("%02X-%02X-%02X-%02X-%02X-%02X"), report->peer_addr.addr[5], report->peer_addr.addr[4], report->peer_addr.addr[3], report->peer_addr.addr[2], report->peer_addr.addr[1], report->peer_addr.addr[0] ); That is, assuming that report->...


2

Actually there are 2 buffers per Serial hardware interface: The hardware buffer, that is 1 byte (per direction of data transfer). The Serial library then transfers this byte in an extra buffer (64 bytes big) from an ISR. Every hardware Serial interface (Serial and Serial1 to 3 on the Mega) has it's own hardware buffer. Then the Serial library is implemented ...


2

The Arduino Mega has 8 KB of RAM, all of which you could use in a StaticJsonDocument. The ESP8266 has 80 KB of RAM, but the core limits the stack to 4 KB. If you need something bigger, switch to a DynamicJsonDocument. In both cases, you need to leave a lot of room for other variables and libraries. As an example, I wouldn't create a StaticJsonDocument bigger ...


1

What do each of the 12 elements represent? Things in the header. That is off-topic for here. Why is there a difference in the output between the output of the raw buffer and snifferPacket? snifferPacket is overlaid over the incoming buffer. That includes the "data" buffer which you are printing. The data buffer is only a portion of the ...


1

Thanks for the pointer - that did the trick. Applying it to my original code, if I update the few lines around handle call from Python to the following, it works as intended. ////////////////////////////////////////////// // handle call from Python myTransfer.rxObj(received_str, CMD_LEN); strncpy(buff, received_str, myTransfer.bytesRead); ...


1

Every instance of class HardwareSerial has own buffers. Here you can see it in source code. The instances are declared/definded at the end of the HardwareSerial.h/.cpp.


1

A byte can only contain values from 0 to 255 (including). So my guess it works for values until 255. You should use a different type, e.g. unsigned int or unsigned short. for (unsigned short i = len; i < 250; i++) buffer[i] = '#'; // pad with # Also, I advise to use a constant or define for the buffer size, now you have 3 values (512, 500 and 250 ...


1

toCharArray is alias for getBytes. getBytes is documented as "Copies the String’s characters to the supplied buffer." You did not allocate the memory for the copied characters. the right use of 'getBytes' and 'toCharArray' is char buffer[BUFF_SIZE]; str.getBytes(buffer, sizeof[buffer]); note: getBytes functions sets the terminating zero of the c-string in ...


1

The communication protocol used by this library is unreliable. Thus, each code word is sent multiple times, 10 times by default. One solution around this problem is to send a “byte number” along with each byte you transmit. You would then transmit 16-bit words, where the MSB (most significant byte) is the byte number, and the LSB is the actual byte you want ...


1

I found my stupid mistake: By using try without catching specific exceptions (I know one shouln't do that) in my Laptop-Server script I didn't recognize that I was trying to send unencoded strings. So, clientsocket.send("hi there, "+str(addr)+"\n") has to be clientsocket.send(bytes(("hi there, "+str(addr)+"\n").encode('utf-8'))) instead.


1

close the disconnected socket before reconnecting if (!client.connected()) { client.stop(); client=TCPserver.available(); }


1

The simple answer is that the Arduino Wire library has an internal buffer, and it can bring in characters and have them sitting there ready for you to pick them up. It can also sense a total disconnect because of the way it uses both data pins to establish communications. It is more like a current loop than a simple one-is-transmit-and-the-other-is-...


Only top voted, non community-wiki answers of a minimum length are eligible