I have so far done the following:
Installed ardulink and configured as /dev/ttyS80
Installed sketch on arduino to recognize and process serial commands.
if i send "echo "digital7|1" > /dev/ttyS80" from terminal window on RPI the command is understood and processed by arduino, Led Turns on.
if i send "echo "digital7|0" > /dev/ttyS80" from terminal window on RPI the command is understood and processed by arduino, Led Turns off.
if i send "echo "digital7|-1" > /dev/ttyS80" from terminal window on RPI the command is understood and processed by arduino, Led reverses state.
I have looked at the serial i/o test and cannot figure out how to send "digital7|1" to /dev/ttyS80
what am i missing? There is definately comms between RPI and Arduino serial port.
I butchered the code and can send data to Arduino.
var portname = "/dev/ttyACM0";
Action<string>
HandleStringReceived = (string message) => {
// this will be called every time a message is received from serial port
Program.Notify("SerialPort String", message);
};
Action<byte[]>
HandleMessageReceived = (byte[] message) => {
// this will be called every time a message is received from serial port
Program.Notify("SerialPort Bytes", BitConverter.ToString(message));
};
Action<bool>
HandleStatusChanged = (bool connected) => {
// this will be called every time the connection status changes
Program.Notify("SerialPort Status", connected ? "CONNECTED!" : "DISCONNECTED!");
};
// open the serial port channel and register handlers
SerialPort
.WithName( portname )
.OnStatusChanged( HandleStatusChanged )
.OnMessageReceived( HandleMessageReceived )
.OnStringReceived( HandleStringReceived )
.Connect( 9600 ); // change baud rate if needed
while (Program.IsEnabled)
{
// send a raw byte message
//byte[] message = { 0x00, 0x00, 0x00, 0x00, 0x00 };
// this is what i changed
SerialPort.SendMessage("digital7|-1");
// pause 5 seconds
Pause(1);
// send a text message
//SerialPort.SendMessage("Hello Things!");
// pause 10 seconds and repeat again
//Pause(10);
break;
}
Arduino responds using this code.
where would i go next to link it to a switch and to accept change on and off - set variables ?