BS2 Linux serial commands or shell script for sending and receiving serial ?
nick03
Posts: 4
Hi, this is my first thread/question....
I have a Basic Stamp 2 and need it to communicate with my Linux server (Debian 6.0.3).
I am trying to use serial to communicate between them (Serin & Serout),
but I am having troubles with the Linux part. I have read about using: echo Value > ttyS1
and it has not worked for me, so i need help to make a shell script to send a Word value
and receive a value.
Thanks in advance.
I have a Basic Stamp 2 and need it to communicate with my Linux server (Debian 6.0.3).
I am trying to use serial to communicate between them (Serin & Serout),
but I am having troubles with the Linux part. I have read about using: echo Value > ttyS1
and it has not worked for me, so i need help to make a shell script to send a Word value
and receive a value.
Thanks in advance.
Comments
I'm currently am using 5 parallel ports with only outputs for my project of controlling all of the lights in my room (a big bundle of wire) and am seeking more i/o's for adding possibility to control a rc car and 3 tv's (as in remote control functions). I just can't get the serial from the server to the Basic Stamp, but am able to use serial for connecting to a XBee to link to other XBee's for control in other areas wirelessly.
I suggest taking a look at Python, which offers you an interactive shell as well as traditional scripting. You can develop your script on Windows, then make the necessary changes to port it to Linux (ie, different serial port names).
Python may not be installed by default on Debian, but it will be in the repo. You'll want to look for a recent 2.x version (2.6 or 2.7), and you'll need to download and install the PySerial module. You'll also need Python on Windows. There are a few different releases, but I suggest ActivePython by ActiveState. It comes with a built-in IDE, but I suggest Komodo Edit or Notepad++ as better choices.
Do you have any recommendations on a way to learn it like a book or something?
As for learning material... if you don't have much programming experience, try this course from MIT. It uses Python to teach the principles of computer science. If you already feel comfortable with basic programming concepts, you can try Learn Python the Hard Way, which is more of a tutorial. There's also the official online documentation.
I would hate to go back to using parallel ports for my project.
It looks like you need to use pins 1 and 2 for serial http://www.parallax.com/Portals/0/Downloads/docs/prod/schem/BS2revJSchematic.pdf
Before you get into shell scripts in Python, BASH, or whatever; you may just want to get your serial port up and running in a Terminal window.
The truth is that the BasicStamps don't require much, but it helps to start out by having the BasicStamp send a prompt character and going on from there or using DEBUG to send a stream of output to your computer as a test.
Take a look at this site for set up. Use Google searches for "Linux HOWTO ?????" for specific topics.
http://linux.koolsolutions.com/2008/04/10/how-to-test-serial-ports-under-debian-linux/
Install 'minicom' and learn how to use it. If you need to use a USB to Serial adapter, that still will accept use of 'minicom'.
In many cases, your shell script can evoke 'minicom' and then redirect standard output, standard input, and standard error as required.
http://www.cyberciti.biz/tips/connect-soekris-single-board-computer-using-minicom.html
http://linux.about.com/od/commands/l/blcmdl1_minicom.htm
http://linux.die.net/man/1/runscript