I am using an Arduino Yun, I connect a device to the USB HOST port, with PUTTY I send a command to the device switch on Remote mode ON « echo -en ‘\xF1\x00\x36\x10\x10\x01\x47’ > /dev/ttyACM0 »
and Remote OFF « echo -en ‘\xF1\x00\x36\x10\x00\x01\x37’ > /dev/ttyACM0 »
it’s ok !
I would use the commands in the Arduino
Here is my sketch but does not work
#include <Process.h>
void setup()
{
Bridge.begin();
Serial.begin(9600);
while (!Serial);
}
David68:
A question: syntax “p.addParameter("\xF1\x00\x36\x10\x10\x01\x47");” Arduino send in ASCII ?
Yes, it sends in ASCII but it is not relevant because the entire string is passed to the linux bridge process and then it runs the full command string.
I just noticed that in
p.addParameter("\xF1\x00\x36\x10\x10\x01\x47");
quotes are missing, while in the command that you run from ssh there are quotes.
The backslash character "" has special meaning in C and C++ strings. It is an ESCAPE SEQUENCE that allows you to add certain unprintable characters to your string. It takes the form of a backslash followed by another character, at which point that character takes on a new meaning. For example, "\r" becomes a carriage return character.
In C and C++, the "\x" escape sequence takes the next two characters, treats them as hexadecimal, and replaces the four characters ("\xNN") with the single character with that hexadecimal code. So, you are actually passing raw binary characters to the echo command.
In your case, you want the backslash character to be part of the string, and you want it to be an ASCII string. To do so, you have to double up the backslashes: "\" when between quotes becomes a single backslash in the resulting string.
ShapeShifter:
::::SNIP::::
In C and C++, the "\x" escape sequence takes the next two characters, treats them as hexadecimal, and
::::SNIP::::
@ShapeShifter,
yeah I think you guys are right. My headache (now 3days) has me in a fog.
Just a note, I've had the annoying issues of having to use three (3) slashes.
I even recall a rare fourth slash
Like this:
jessemonroy650:
Just a note, I've had the annoying issues of having to use three (3) slashes.
I even recall a rare fourth slash
Like this:
"'\\\xF1\\\x00...
That code with triple slashes will result in a string containing a backslash character, then a character with the binary value 0xf1, then another backslash character, then a NULL character with a binary value of 0x00, and so on.
Four backslashes in a row will put two backslashes in the string.
ShapeShifter:
The backslash character "" has special meaning in C and C++ strings. It is an ESCAPE SEQUENCE that allows you to add certain unprintable characters to your string. It takes the form of a backslash followed by another character, at which point that character takes on a new meaning. For example, "\r" becomes a carriage return character.
Yeah, you're right! I was thinking to read the bridge library to find the problem, you saved me a lot of time