Hey,
I've seen that it may be possible to send the Arduino a serial command from Terminal on a Mac using something like:
./arduino-serial -b 9600 -p /dev/tty.usbmodemb21 -d 2000 -s a
That particular command has as error, " No such file or directory".
Any idea what may work?
Thanks,
Carl
Using Terminal for Serial Commands
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- cstratton
- Posts: 294
- Joined: Wed Sep 29, 2010 3:52 pm
Re: Using Terminal for Serial Commands
On a unix-like os, saying './arduino-serial' instructs the shell to run a program found in the current directory, rather than to search the path for that command. So this would only work if you are currently in the directory where that is found.
You can try it without the ./ - just type 'arduino-serial' and the rest of the command line and see if it is found then.
If not, you would have to figure out where this program comes from and where it lives that's not in the path, or how to install it.
However, there's no real requirement that you use that program. If you are using the arduino IDE, there's probably a serial monitor available in the drop down menu.
And surely there are many generic terminal emulator programs available for the Macintosh. You just need one where you can put in the special device string for the serial port, and have it not send modem control AT commands (since the arduino is not a modem). If it twiddles with flow control lines, you may have to wait a bit after starting it for the bootloader to time out and your sketch to start up.
You can try it without the ./ - just type 'arduino-serial' and the rest of the command line and see if it is found then.
If not, you would have to figure out where this program comes from and where it lives that's not in the path, or how to install it.
However, there's no real requirement that you use that program. If you are using the arduino IDE, there's probably a serial monitor available in the drop down menu.
And surely there are many generic terminal emulator programs available for the Macintosh. You just need one where you can put in the special device string for the serial port, and have it not send modem control AT commands (since the arduino is not a modem). If it twiddles with flow control lines, you may have to wait a bit after starting it for the bootloader to time out and your sketch to start up.
-
- Posts: 36
- Joined: Tue Oct 11, 2011 2:19 am
Re: Using Terminal for Serial Commands
Thanks. Tried using just: arduino-serial -b 9600 -p /dev/tty.usbmodemb21 -d 2000 -s a
but returns "command not found"
Being a complete noobie at this I'm not sure where or what the arduino-serial is or where it may be.
Did a search on it and came up empty.
Is there some other command that may work with Terminal that may work?
Thanks,
Carl
but returns "command not found"
Being a complete noobie at this I'm not sure where or what the arduino-serial is or where it may be.
Did a search on it and came up empty.
Is there some other command that may work with Terminal that may work?
Thanks,
Carl
- cstratton
- Posts: 294
- Joined: Wed Sep 29, 2010 3:52 pm
Re: Using Terminal for Serial Commands
Within the arduino environment, "Click the serial monitor button in the toolbar and select the same baud rate used in the call to begin(). "
-
- Posts: 36
- Joined: Tue Oct 11, 2011 2:19 am
Re: Using Terminal for Serial Commands
Thanks, did that, but still no joy.
Carl
Carl
- cstratton
- Posts: 294
- Joined: Wed Sep 29, 2010 3:52 pm
Re: Using Terminal for Serial Commands
Why, what happened when you clicked the serial monitor button?ckeyes wrote:Thanks, did that, but still no joy.
-
- Posts: 36
- Joined: Tue Oct 11, 2011 2:19 am
Re: Using Terminal for Serial Commands
It works fine from the serial monitor in the Arduino app if I enter an "a", or whatever.
I just need to send the same command from Terminal.
Thanks,
Carl
I just need to send the same command from Terminal.
Thanks,
Carl
-
- Posts: 295
- Joined: Sat Dec 11, 2010 1:17 am
Re: Using Terminal for Serial Commands
From the Terminal command prompt, you can use the 'screen' command to connect to the Arduino and then send commands through that.
will 'connect' you to the Arduino, assuming the arduino is '/dev/tty.usbmodem621'. Then whatever you type in terminal is sent directly to the Arduino. To exit out of screen, you have to type Ctrl-A then Ctrl-\.
You can read some more info about using screen here: http://hints.macworld.com/article.php?s ... 9133825654
Edited to add - if you want to use something like a shell script to send commands rather than using the terminal, then I think you can use echo to send text to the Arduino, like this:
Cheers!
Code: Select all
screen /dev/tty.usbmodem621
You can read some more info about using screen here: http://hints.macworld.com/article.php?s ... 9133825654
Edited to add - if you want to use something like a shell script to send commands rather than using the terminal, then I think you can use echo to send text to the Arduino, like this:
Code: Select all
echo "some text" > /dev/tty.usbmodem621
- cstratton
- Posts: 294
- Joined: Wed Sep 29, 2010 3:52 pm
Re: Using Terminal for Serial Commands
If using those data-only solutions you may need to use something like stty to set the baud rate for the computer end if it hasn't been previously set by running something such as the arduino IDE since boot.
There may also be tty control bit settings which could cause unintended auto resets to the bootloader on port open/close.
There may also be tty control bit settings which could cause unintended auto resets to the bootloader on port open/close.
-
- Posts: 36
- Joined: Tue Oct 11, 2011 2:19 am
Re: Using Terminal for Serial Commands
screen /dev/tty.usbmodemb21
returns a "Sorry, could not find a PTY"
Any help?
Thanks,
Carl
returns a "Sorry, could not find a PTY"
Any help?
Thanks,
Carl
- cstratton
- Posts: 294
- Joined: Wed Sep 29, 2010 3:52 pm
Re: Using Terminal for Serial Commands
Hmm, not having a mac to play with... that does look like the usual syntax on unix-ish systems though
are you sure that the specified device file is (still) the correct one for the arudino?
What do you get if you ls -l that device file?
Does the arduino IDE or its serial monitor still have the port open
IIRC macs don't have the issue with non-root users accessing usb peripheral device files that cause us to write udev rules on linux
Just thinking out loud...
are you sure that the specified device file is (still) the correct one for the arudino?
What do you get if you ls -l that device file?
Does the arduino IDE or its serial monitor still have the port open
IIRC macs don't have the issue with non-root users accessing usb peripheral device files that cause us to write udev rules on linux
Just thinking out loud...
- baldengineer
- Posts: 127
- Joined: Sun Sep 26, 2010 11:49 pm
Re: Using Terminal for Serial Commands
Not a surprise, there is no command called "arduino-serial".ckeyes wrote: ./arduino-serial -b 9600 -p /dev/tty.usbmodemb21 -d 2000 -s a
That particular command has as error, " No such file or directory".
type:ckeyes wrote:screen /dev/tty.usbmodemb21
screen /dev/tty.usbmodem<TAB>
<TAB> is the auto-completion for bash. once the file name / serial handle is completed add 9600 to the end of the command line.
Once screen is running, press <CTRL>-A, <CTRL>-\ to exit.
-
- Posts: 36
- Joined: Tue Oct 11, 2011 2:19 am
Re: Using Terminal for Serial Commands
Thanks James, but you lost me. Not sure what you mean by this: "once the file name / serial handle is completed add 9600 to the end of the command line."
Sorry, complete noob at this.
Carl
Sorry, complete noob at this.
Carl
- baldengineer
- Posts: 127
- Joined: Sun Sep 26, 2010 11:49 pm
Re: Using Terminal for Serial Commands
Sorry, then you probably shouldn't be mucking around in the terminal.
What were you trying to do at a high level?
What were you trying to do at a high level?
-
- Posts: 36
- Joined: Tue Oct 11, 2011 2:19 am
Re: Using Terminal for Serial Commands
Simply send the Arduino an "a".
Carl
Carl
Please be positive and constructive with your questions and comments.