Unable to send a complete string to shell prompt via Serial Interface

1 view (last 30 days)
Hello,
I am trying to send a string command to shell prompt so that I can trigger an event.
However when I send the command, the shell prompt does not receive it exactly as I sent it.
It somehow gets formatted automatically in an order that makes it an invalid command.
The command that I am trying to send:
./pb -r cecon -n CeConIF.ContentReq -c “cmd:1, conf_id:0, provider_session_id:0, source_id:2
The way I send it to shell via serial port:
log_serial_port(s1,1,'./pb -r cecon -n CeConIF.ContentReq -c “cmd:1, conf_id:0, provider_session_id:0, source_id:2”')
log_serial_port is a function written to send string to serial port s1.
When I send the command via log_serial_port function, I receive the following :
./pb -r cecon -n CeConIF.ContentReq -c cmnIF.ContentReq -c cmd:1, conf_id:0, provider_session_id:0, source_id:2
ProtoBuf Error: Error parsing text-format CeConIF.ContentReq: 1:1: Expected identifier.
Failed to parse input.
255|root@android:/opt/beta/bin #
Here after ./pb -r cecon -n CeConIF.ContentReq, the command got automatically formatted. Hence, Linux was unable to recognize it and hence I got an error 'Failed to parse input'.
I am not sure whats happening here and why MATLAB autoformats the command before sending it to Shell.
Any help is appreciated.
Thank you,
Bhushan

Accepted Answer

Walter Roberson
Walter Roberson on 17 Nov 2015
You need
log_serial_port(s1,1,'./pb -r cecon -n CeConIF.ContentReq -c "cmd:1, conf_id:0, provider_session_id:0, source_id:2"')
The difference is that you used "smart quotes" and I used "straight quotes". Your receiver is getting
./pb -r cecon -n CeConIF.ContentReq -c ?cmnIF.ContentReq -c ?cmd:1, conf_id:0, provider_session_id:0, source_id:2?
which is
./pb -r cecon -n CeConIF.ContentReq -c “cmnIF.ContentReq -c “cmd:1, conf_id:0, provider_session_id:0, source_id:2”
to use HTML representation. That is, the two ? are char(hex2dec('93')) and the ? is char(hex2dec('94')), but your receiver is expecting " which is " which is char(hex2dec('22'))

More Answers (1)

Bhushan
Bhushan on 17 Nov 2015
Didn't notice that. Thanks for solving it for me. The straight quote works.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!