rc-switch and bash commands

Hello.
First of all this concept was main reason i ended up buying arduino :frowning:

Im trying to set up router with custom firmware (tomato based) and on that router device is recognised as /dev/ttyACM0

For example

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10);
}
void loop() {
mySwitch.switchOn("11001", "01000");
}

works perfect with my setup - device connected to receiver responds and turns on.
The question is - how can i control that from bash on router.
I tried with:

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10);
}
void loop()
{
}

uploaded to arduino
and echo command to arduino:

echo "mySwitch.switchOn("11001", "01000");" > /dev/ttyACM0

but it doesnt seem to work
arduino is blinking and RF transmitter is not :frowning:
any sugestions for arduino and linux newbie?
Thank You in advance.

I'm not sure I can help, but I have experience using Tomato and WRT54g as a lawn sprinkler pump controller and I'm interested in what you're attempting.

As I understand it your using a router that has a usb host port into which you've plugged the Arduino? Or, you have wired up the router RX/TX outputs to Arduino. (which)

What does "Works perfect with my setup" mean? (Obviously not working perfect otherwise you would not be asking).

I suspect what may be missing is your understanding that there needs to be some Arduino code in setup() and loop() which will be looking to read characters from the serial port (which were sent by your bash script), interpreting them, and then sending something appropriate to "mySwitch". But I'm not quite sure, I may be misinterpreting what you've tried. Also, I am not familiar yet with RCSwitch so I'm not sure what type of commands you're wanting to send.

It might be as simple as (gross pseudcode):

void loop:
  cumulate characters from serial 
  if I've received 10 characters:
     split into first5chars and second5chars
     mySerial.switchOn( first5chars, second5chars)

But I kinda doubt it :slight_smile:

Cheers,
John