Pages: [1]   Go Down
Author Topic: Bash comm. with arduino uno over ttyACMx  (Read 1703 times)
0 Members and 1 Guest are viewing this topic.
austria
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I stuck with my work and dont know what to do. Maybe somebody can give me some help.I am trying to get a LED on over a bash command line on linux.
There allready a few post in forum but didnt work for me.

When i enter  echo "1" > /dev/ttyACM0     in cmd line i see the communication leds on the board flicker and also the LED on Output 13 flickers, (3 or 4 times) but dont stay on like in code written.
If i send 12345678987654321 > /dev/ttyACM0 it is the same result. On my arduino is no ftdi chip. Is that the reason it doesnt work?


code:

void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop()
{
  if (Serial.available() > 0)
  {
    int incoming = Serial.read();
   
    if ((char)incoming == '1')
    {
      digitalWrite(13, HIGH);
      Serial.println("On");
    }
    else if ((char)incoming == '2')
    {
      digitalWrite(13, LOW);
      Serial.println("Off");
    }
  }
}


thanks
Logged

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

portspeed ?

Code:
stty -F /dev/ttyACM0 9600

does it work with screen ?

Code:
screen /dev/ttyACM0
Logged

• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

austria
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Portspeed is set to 9600. I have connected the Arduino to a dreambox(linux TV receiver) and so i dont have screen available.
Logged

Atlanta, GA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

is the arduino resetting on your connection?

Have you tried sending data from the arduino to your box first?
vary the data sent so you can verify it's not resetting on each connection.
/opt/bin/head -n2 /dev/ttyUSB0

the -n2 will return two lines

if you don't have screen - what about picocom?

picocom -r -b 9600 /dev/ttyUSB0
the -r is a noreset switch on exit



Logged

austria
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

picocom is also not available on dreambox. i connected Arduino with ubuntu and it worked:


andi@andi-netbook:/dev$ picocom -r -b 9600 /dev/ttyACM0
picocom v1.4

port is        : /dev/ttyACM0
flowcontrol    : none
baudrate is    : 9600
parity is      : none
databits are   : 8
escape is      : C-a
noinit is      : no
noreset is     : yes
nolock is      : no
send_cmd is    : ascii_xfr -s -v -l10
receive_cmd is : rz -vv

Terminal ready
On
Off
Off
On
Off
Off

And i also get the messages correctly back, On, Off. Thats exactly that what i would need for the linux receiver.

Logged

austria
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i found a screen package for dreambox
when i enter screen -e '1' > /dev/ttyACM0

i get exactly the same result. The led flicker a few times and thats it.

and found a picocom package for the box.
with picocom -b 9600 /dev/ttyACM0 i can set the led correctly! -great!!!!

how can i kill the terminal ?Once i have open picocom i cant stop?

Any idea because it dosnt work the usual way with echo?
thanks

« Last Edit: July 31, 2011, 03:59:23 pm by andil » Logged

Atlanta, GA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

to kill pico have to use the ctrl but I've not figured out actual what it wants - so I do ctrl-a, ctrl-x, ctrl-c until it stops - some times toss a shift in too!

did you try with the head command?
head -n10 /dev/ttyUSB0

Logged

austria
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes have tried head -n10 /dev/ttyACM0 as well
same like allways ,led is flicker 3times and thats it.

Next week i get the decimiela board with the ftdi chip onboard. i am really curious what will happend then.
is the behaving different in any case between ttyACM0 and /ttyUSB0 ?
perfect for me would be if i have succes with      echo "1" > /dev/ttyACM0. Makes it easy for some scripts wich i can start over the GUI on receiver.
Thank you for your information
« Last Edit: July 31, 2011, 04:47:10 pm by andil » Logged

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect the behaviour will be the same.

Most likely you need to disable auto-reset. I wish they had added a jumper back then instead of the solder bridge. You can shut it off by adding a capacitor.

http://arduino.cc/forum/index.php/topic,62138.msg450033.html#msg450033
Logged

• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

austria
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Many Thank for that hint!!! My solution is a little bit different. I connect a 2,2 microfarad electrolytic capacitor between the 5V+ and the reset on the arduino uno.

And now i can send    echo 1 > /dev/ttyACM0  to the arduino and the led is on. COOOOOL!

Thank you very much for help!! Works brilliant!!!
Logged

Pages: [1]   Go Up
Jump to: