A thread documanting my trials and tribulations using a serial port in Linux. May eventually turn into a tutorial. I have been looking for a hterm or bray's terminal substitute for use under Linux, but there seems to be little info on what and how to make stuff work.
My current setup:
Fedora core 8
Keyspan USA-19HS usb to serial adapter
Luckily my Keyspan usb to serial adapter was automatically recognized and set up as /dev/ttyUSB2 by Fedora. Run
after you plug in the adapter to see if the device was set up. You should see something like:
usb 7-1: new full speed USB device using uhci_hcd and address 6
usb 7-1: configuration #1 chosen from 2 choices
keyspan 7-1:1.0: Keyspan 1 port adapter converter detected
usb 7-1: Keyspan 1 port adapter converter now attached to ttyUSB2
The last line tells you that the adapter was set up as ttyUSB2. Check the dev folder by running
ls -al /dev/ttyUSB*
crw-rw---- 1 root uucp 188, 2 2008-03-13 12:30 /dev/ttyUSB2
**Important note: "Permission denied" errors
Notice that /dev/ttyUSB2 is owned by the root user and the uucp group. You might get "Permission denied" errors when trying to use the /dev/ttyUSB2 port if you are not root or a member of the uucp group. There are a couple of options around this.
A) 'su' to root
B) prefix 'sudo' to your commands. ex: 'sudo stty -F /dev/ttyUSB2 9600'
C) add yourself to the uucp group. 'gpasswd -a me uucp'
D) make the /dev/ttyUSB2 device readable and writable to everyone. sudo chmod 0666 /dev/ttyUSB2
E) create a udev rule to make the /dev/ttyUSB2 device readable and writable by everyone whenever the adapter is plugged in. (too complicated to explain here)
Set up the baud rate with the stty command. I'm using 115200, so I run
stty -F /dev/ttyUSB2 115200
. To verify the settings, run
stty -F /dev/ttyUSB2
speed 115200 baud; line = 0;
min = 1; time = 5;
ignbrk -brkint -icrnl -imaxbel
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
You can do some very primitive debugging. Receive data from the STK500 by opening a terminal window and running
You can send characters by running
echo "send this" > /dev/ttyUSB2
But it would be really much better if all this could be done inside one program, and maybe get some hex or binary viewing too.
* HTerm under Wine
* Bray's Terminal under Wine
HTerm and Wine
I installed wine using yum.
sudo yum install wine
Setup the serial port to be recognized by wine. Create a symbolic link to /dev/ttyUSB2 in ~/.wine/dosdevices. (run 'wine hterm.exe' first so that wine can create the ~/.wine directory).
ln -s /dev/ttyUSB2 ~/.wine/dosdevices/com5
I chose com5 because I already had /dev/ttyS0 thru /dev/ttyS3 which get mapped to com1 thru com4 in wine.
I can run HTerm in Wine,
cd ~/hterm && wine hterm.exe
but HTerm doesn't seem to recognize my serial ports under Wine. I can connect to com5, but nothing really happens. There's an error in the console: 'fixme:comm:set_queue_size insize 4096 outsize 4096 unimplemented stub' so maybe HTerm is calling something that isn't implemented in Wine. Also, there's something glitchy about the cursor placement when you type in text. The cursor is about one character in front of where it should be.
Bray's Terminal and Wine
Bray's website http://bray.velenje.cx/avr/terminal seems down right now, but I downloaded terminal.exe from here http://www.myplace.nu/mp3/download.htm (scroll down to the "Tools and Others" section)
Set up the serial ports as described in the above HTerm section.
cd ~/bray && wine terminal.exe
Bray's terminal actually works when you connect! :)
I finally got minicom working, although I don't really like minicom. It's like running hyperterminal in windows... yucky.
Run the minicom setup.
sudo minicom -s
Go to Serial port setup and set the Serial Device to /dev/ttyUSB2. (Press A to change the Serial Device, and press Enter when you are finished to go back to the menu)
Press E to set the baud rate (Bps/Par/Bits). I'm using 115200 bps. If you know what stop bits and stuff you need to use, set it here. If you don't know, I think '8N1' is pretty standard and should work. My setting reads 115200 8N1
Press F to set the Hardware flow control to 'No'.
Press G to set the Software flow control to 'No'.
Leave Callin Program and Callout Program blank. (I have no clue what these do)
Press Enter to go back to the main menu.
Go to the Modem and dialing menu. I'm not sure if this is necessary, but I deleted all of the strings in here. Press Enter to go back to the main menu.
Go to the Screen and keyboard menu. Press Q and set the Local echo setting to Yes. This allows you to see what you are sending over the serial connection in the terminal. Press Enter to go back to the main menu
Choose Save setup as dfl then Exit the minicom setup. It should start up minicom.
In the minicom window you should be able to start typing to send characters. Press 'ctrl-a z' to see a list of menu options. I have to go to the menu and set the local Echo to off then on each time to see my input, even though it's supposed to be saved in the settings
I try running picocom
sudo picocom --baud 115200 /dev/ttyUSB2
but I'm not sure if it's working. Press 'ctrl-a x' to exit the program.
Go to Configuration => Port and setup the device and baud rate. Turn on the Local Echo by making sure Configuration => Local Echo is checked. Now start typing!
There was no cutecom package in yum, so I have to compile it myself. I downloaded 0.20.0 from their site http://cutecom.sourceforge.net
su - yum install qt4-devel.x86_64 cmake tar xzvf cutecom-0.20.0.tar.gz cd cutecom-0.20.0 less README
The README says to make sure to use qt4's qmake. Check which qmake is in your path with
This returns '/usr/lib64/qt-3.3/bin/qmake' for me, which is qt3's qmake. Find where yum put qmake for qt4
find / -name qmake 2>/dev/null
Looks like qt4's qmake is at /usr/lib64/qt4/bin/qmake. Add this to the PATH variable like it says to do in the README
export PATH=/usr/lib64/qt4/bin:$PATH cmake . make make install
The install went ok. Running Cutecom opens up a nice Bray-esque interface. :)