Php Serial Port Communication Linux Mint
Once the device is visible to the system, applications (including stty) do not know or care whether the serial port is a virtual one over USB, or any other low level hardware details about the way the device is implemented - the driver and the kernel hide all that from applications. That's how Unix/Linux is supposed to work.
I am trying to connect minicom to a serial device that is connected via a USB-to-serial adapter. This is a PL2303 and from everything I've read no additional drivers are required. The device is recognised as a PL2303.
I'm a beginner at minicom. Is this the correct command to execute? Or do I need to configure something?
Peter Mortensen10 Answers
First check with dmesg grep tty
if system recognize your adapter.Then try to run minicom with sudo minicom -s
, go to 'Serial port setup' and change the first line to /dev/ttyUSB0
.
Don't forget to save config as default with 'Save setup as dfl'. It works for me on Ubuntu 11.04 on VirtualBox.
MatejMatejYou will need to set the permissions every time you plug the converter in.I use PuTTY to connect. In order to do so, I have created a little Bash script to sort out the permissions and launch PuTTY:
P.S. I would never recommend that permissions are set to 777.
Peter MortensenThe serial port communication programs moserial
or gtkterm
provide an easy way to check connectivity and modify /dev/ttyUSB0
(or /dev/ttyUSB1
!) settings. Even though there maybe only a single USB to RS232 adapter, the n
designation /dev/ttyUSBn
can and does change periodically! Both moserial
and gtkterm
will show what port designation is relevant in their respective pull down menus when selecting an appropriate port
to use.
Check out help.ubuntu.com/community/Minicom for details on minicom
.
I had fix this with adduser *username* dialout
. I never had this error again, even though previously the only way to get it to work was to reboot the PC or unplug and replug the usb to serial adapter.
I get get the same minicom error, 'cannot open /dev/ttyUSB0: No such file or directory'
Three notes:
I get the error when the device attached to the serial port end of my Prolific Technology PL2303 USB/Serial adapter is turned off. After turning on the device (an embedded controller running Linux) minicom connected fine.
I have to run as super user (i.e.
sudo minicom
)Sometimes I have to unplug and plug back in the USB-to-serial adapter to get minicom to connect to it.
I am running Ubuntu 10.04 LTS (Lucid Lynx) under VMware (running on Windows 7). In this situation, make sure the device is attached to VM operating system by right clicking on the USB/Serial USB icon in the lower right of the VMware window and select Connect (Disconnect from Host).
Remember to press Ctrl + A to get minicom's prompt, and type X to exit the program. Just exiting the terminal session running minicom will leave the process running.
Peter MortensenI had the exact same problem, and it was fixed by doing a chmod 777 /dev/ttyUSB0
. I never had this error again, even though previously the only way to get it to work was to reboot the VM or unplug and replug the USB-to-serial adapter. I am running Ubuntu 10.04 (Lucid Lynx) VM on OS X.
Linux Serial Port Communication
Long time reader, first time helper ;)
I'm going through the same hellish
experience here with a Prolific USB <> Serial adapter and so far Linux is the easiest to get it to work.
On CentOS, I didn't need to install any drivers etc.. That said,
dmesg grep -i tty
ordmesg grep -i usb
showed me /dev/ttyUSB0.screen ttyUSB0 9600
didn't do the trick for me like it did in OSX- minicom is new to me but it was complaining about lack of /dev/modem
However, this helped: https://www.centos.org/forums/viewtopic.php?t=21271
So install minicom (yum install minicom
) then enter its settings (minicom -s
).
Then select Serial Port Setup
and change the Serial Device (Option A) to /dev/ttyUSB0, or whatever your device file is as it slightly differs per distro.
Then change the Bps (Option E) to 9600 and the rest should be default (8N1 Y N)
Save as default, then simply minicom
and Bob's your uncle.
HTH.
I suggest that newbies connect a PL2303 to Ubuntu, chmod 777 /dev/ttyUSB0 (file-permissions) and connect to a CuteCom serial terminal. The CuteCom UI is simple intuitive. If the PL2303 is continuously broadcasting data, then Cutecom will display data in hex format
gatorbackgatorbackI just got my GUC232A cable with a molded-in PL2302 converter chip.
In addition to adding myself and br to group dialout
, I found this helpful tip in the README.Debian file in /usr/share/doc/bottlerocket
:
This package uses debconf to configure the /dev/firecracker symlink, should you need to change the symlink in the future run this command:
dpkg-reconfigure -pmedium bottlerocket
That will then prompt you for your new serial port and modify the symlink. This is required for proper use of bottlerocket.
I did that and voila! bottlerocket is able to communicate with my X-10devices.
Peter MortensenPutty on ubuntuThere is no need to install the driver for PL2303So only type the command to enable the puttySudo chmod 666 /dev/ttyUSB0DoneOpen the putty.
Not the answer you're looking for? Browse other questions tagged linuxserial-portusbhardware-interface or ask your own question.
From windows I can communicate with a serial port device using following commands:
Device starts the requested operation.
When I try to accomplish the same operation from a stand alone debian box or from a debian virtualbox instance of the same windows machine, I had no luck so far.
Here's equivalent linux commands(at least I think so)
Nothing happens.
Can somebody please direct me to the right direction?
MPelletier3 Answers
will not be interpreted, and will literally write the string x12x02
(and append a newline) to the specified serial port. Instead use
which you can construct on the command line by typing CtrlVCtrlR and CtrlVCtrlB. Or it is easier to use an editor to type into a script file.
The stty
command should work, unless another program is interfering. A common culprit is gpsd
which looks for GPS devices being plugged in.
If you want to use hex codes, you should add -e
option to enable interpretation of backslash escapes by echo (but the result is the same as with echo
CtrlRCtrlB). And as wallyk said, you probably want to add -n
to prevent the output of a newline:
Also make sure that /dev/ttyS0
is the port you want.
SCREEN:
NOTE: screen is actually not able to send hex, as far as I know. To do that, use echo
or printf
I was using the suggestions in this post to write to a serial port, then using the info from another post to read from the port, with mixed results. I found that using screen is an 'easier' solution, since it opens a terminal session directly with that port. (I put easier in quotes, because screen has a really weird interface, IMO, and takes some further reading to figure it out.)
You can issue this command to open a screen session, then anything you type will be sent to the port, plus the return values will be printed below it:
(Change the above to fit your needs for speed, parity, stop bits, etc.) I realize screen isn't the 'linux command line' as the post specifically asks for, but I think it's in the same spirit. Plus, you don't have to type echo and quotes every time.
ECHO:
Follow praetorian droid's answer. HOWEVER, this didn't work for me until I also used the cat command (cat < /dev/ttyS0
) while I was sending the echo command.
PRINTF:
I found that one can also use printf's '%x' command:
Again, for printf, start cat < /dev/ttyS0
before sending the command.