Device operations control from software

Status
Not open for further replies.

timsanr

Member level 1
Joined
Apr 13, 2012
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,596
Hi,

I need programming advice. I suppose you met that problem and there are some typical solutions.
I have device which can interpret some commands and then do some related operation. I communicate with it via FTDI USB circuit. My problem is that receiving loop detects if incoming byte is e.g x"55" and if it is true, device sends hex data to PC. But it is also possible send data to device and it can contain x"55" values so device makes bad interpretation and starts to send data to PC.
What is a typical approach in such communication to avoid described situation? I can of course reprogram PC and device software.

It may seem to be stupid question but now I don't know how to do it the best way.

Regards
Tim
 

I'm not sure I understood 100% what the problem was, but I think you're saying that you want to distinguish commands from data.
The information here is not specific to USB:
Often a long sequence is used for the command, i.e. something that is extremely unlikely to occur in the data.
For example, if you sent the characters "___cmd" instead of 0x55 then it is unlikely that they would ever occur in data.
Or, never send raw data, always encapsulate it, e.g. have a header that identifies it as data, and have a length parameter.
 
Yes, it is exactly what I need
I think encapsulation. After data analysis, it is too big likelihood that command can occur in data.

Thank you.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…