-1

The project I’m working on will be interfacing a Netduino 3 WIFI (C# .NET micro Framework) and a PC application (C# .NET Framework). A serial TTL camera will be connected to one of the Netduino’s COM ports and the PC app will connection to another COM port. All will communicate via 8 bit UART. I have been successful in sending and receiving byte[] between the PC, Netduino, and Camera which serve the purpose of sending and acknowledging commands. The main goal is to be able to send the ‘take image’ command to the camera and catch the .JEPG byte[] coming back. I want to start receiving the data once the data received event occurs. I’m not finding much information online but from what I’ve read I may have to use the serialport.basestream property, or a Bitmap Constructor (Stream). I’m just not very familiar with the concept of streams and hope someone could point me to some information or give an example of how to set this up.

R Mason
  • 1
  • 2
  • The serial port should be set to 8 bit no parity. When sending the jpeg precede the binary data with a 4 (or 8 bit) length. Then just send data as bytes. The receive end should strip off the length from the beginning of data and then read bytes (binary data). – jdweng Sep 30 '17 at 10:01

1 Answers1

0

I would suggest that you set the port ReadTimeout to zero and install a handler on the DataReceived event. This can then capture and buffer your data directly into a byte array of the correct dimension if you send an appropriate header before sending the data (a simple checksum probably wouldn't go amiss either). The handler would need to cope with the data being processed in chunks but, once you receive it all, you can process the byte array to reconstruct the jpg and throw it away. The DataReceived event is not raised for each byte, so once you are in there you will need to keep issuing Reads on the port until it returns zero bytes before exiting the handler.

Kevin Ford
  • 260
  • 1
  • 7