danjulio / tCam

Thermal imaging cameras based on the ESP32 and Lepton 3.5
GNU General Public License v3.0
103 stars 25 forks source link

Add length in response data #4

Closed zhaocundang closed 1 year ago

zhaocundang commented 1 year ago

hi dan, why not add 16-bit length of response json data ? for example, I send requst cmd “get_image” ,then device reponse 0x02 {json length}{json}0x03

danjulio commented 1 year ago

Hello! I think using the out-of-band delimiters allows for a more reliable stream parser. They allow you to a) easily cut out the json string to hand to a parser and b) allow fast stream recovery in case there is data corruption (e.g. with the serial link).

I appreciate that some people use a length field followed by data but the existing OOB system works and there is already a bunch of software built around it. Adding the length would break everything and cause me a huge amount of work so I must respectfully decline this feature request.

Regards, Dan