Thursday, July 26, 2012

osx serial communication using "screen" command in terminal

UPDATE
*Apparently minicom would be the osx equivalent to cutecom.
*USB to serial communication has many different drivers. and it all depends on what chip is being used.  I used to find a lot of site talking about a usb to rs232 wire and what made the wire work was a small chip inside of it.  Two big companies made those chips, PL and FTD.  In order to do serial com in terminal you first need the right drivers.  The driver must be the one for the corresponding chip.
Since I was using a spartan 6 I had to take a look at the documentation to find out which chip.  When I plugged it in to my windows machine, it would automatically download the drivers so I never gave it much of a thought.  However, I do not believe osx does this.  The spartan 6 documentation said that the uart had a ftd chip so I went ahead and downloaded the osx driver.
===============
In linux we have cutecom.
In windows we have hyperterminal/terminte
of osx, we have neither.

The purpose of these programs is to help will serial communication such as rs232 protocol.
In my UART fpga lab i had to send a byte of data to the cutecom.  If I did
the protocol correctly, the byte would show up on the screen.
(i.e. fpga sends the char "x" the cutecom shows x)
The reverse also works.  The cutecom can send the fpga the byte
(i.e. cutecom sents char "Z" the fpga shows "Z" in the led's)

I really do wonder why there isn't a nice program for osx.  After searching for it on google
it appears that there are special adapters for rs232 to usb.  Its not really what I was looking for.

IF there was no program like cutecom then there had to be at least SOME way to communicate with the
usb com.

Apparently  you can use the actual terminal

http://www.tigoe.net/pcomp/resources/archives/avr/000749.shtml

I believe a good side project would be to create your very own "cutecom" for the osx.
You would have to figure out how to use it though.....

look into it by using "man screen"

--===========================
--original doc reproduced below
-------------------------------------------

Serial Communication in OSX Terminal

I knew it had to be possible to view serial data in the OSX terminal window, but I'm not enough of a unix geek to figure it out. Finally, a little googling told me what I needed to know. Here's how to read and send serial data from the terminal in OSX.
First, open Terminal. If you've never used it before, it's under Applications/Utilities/Terminal. Next, type
ls /dev/tty.*
to get a list of all of your serial ports. Pick the one that you want to open. For example, my list looks like this:
/dev/tty.BTRS232                        /dev/tty.Tigoe6630-AppleAgent-1
/dev/tty.Bluetooth-Modem                /dev/tty.Tigoe6630-Dial-UpNetwor-2
/dev/tty.KeySerial1                     /dev/tty.modem
And I know from previous experience that /dev/tty.Keyserial1 is my Keyspan USB-to-serial adaptor. It's connected to a PIC at the moment. The PIC's programmed to read one byte of serial data at 9600 bits per second, then send back three bytes, "A", "B" and "C".
Knowing the serial port, you can just type screen portname datarate to show the serial data on the screen. In my case, it was:
screen /dev/tty.Keyserial1 9600
Then I started typing bytes at the PIC, and it sent bytes back to me. Whee! No need for zTerm! To quit the screen app, tyoe control-A, then control-\.

No comments:

Post a Comment