LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-15-2010, 08:26 AM   #1
raphtor
Member
 
Registered: Aug 2008
Location: india
Posts: 174

Rep: Reputation: 30
setting up serial communication from desktop through USB port in linux terminal


I am new to linux terminal programming and all but i want to set up a simple serial communication from my desktop through USB port. The actual idea to to write some data in the terminal and build a terminal program that sends the data to the usb port with a fixed baud rate. are there ready made terminal programs available for this simple communication?or atleast any Graphical tools which could help me build and design such a terminal in ubuntu 9.04?
 
Old 01-16-2010, 01:07 AM   #2
Elemecca
Member
 
Registered: Nov 2008
Location: San Francisco, CA
Distribution: Gentoo, CentOS
Posts: 71

Rep: Reputation: 22
USB is a packetized bus with many device types, so there is no one thing called USB to send data to. What type of device are you trying to communicate with? What are you trying to do with it?
 
Old 01-17-2010, 01:24 AM   #3
raphtor
Member
 
Registered: Aug 2008
Location: india
Posts: 174

Original Poster
Rep: Reputation: 30
well i am trying to establish a serial connection between the desktop and RS232 interface on my dev board.The objective is to build a terminal program which will transmit what ever character i type in the terminal with to fixed baud rate to the board interface...
 
Old 01-18-2010, 11:10 AM   #4
Elemecca
Member
 
Registered: Nov 2008
Location: San Francisco, CA
Distribution: Gentoo, CentOS
Posts: 71

Rep: Reputation: 22
OK, so the device on the other end of the cable is an RS-232 adapter. Linux has drivers for a lot of those. What you want to do is get it to show up as a TTY (probably /dev/ttyS0) so you can attach a terminal emulator to it. With the device plugged in, run 'lsusb' from a root terminal. It will print one line for each USB device on your system. Look for the line describing your device and post it. If you can't find it, just post the whole thing.
 
Old 01-18-2010, 11:36 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
If your dev board's USB port is a USB serial port adapter then it might already be recognized as /dev/ttyUSB0. Check the output of the dmesg command. Also post the output of the lsusb command. The output will display the chipset information. You can use minicom to communicate with the board or search for linux serial programming to help you get started with writing your on program

http://tldp.org/HOWTO/Serial-Programming-HOWTO/
 
Old 08-06-2010, 11:03 AM   #6
cadd
LQ Newbie
 
Registered: Aug 2010
Posts: 16

Rep: Reputation: 0
Hi,

I am having same problem.

I want to send/receive data via usb port in C on Linux machine

my dmesg output is

[15246.867897] usb 1-2: pl2303 converter now attached to ttyUSB0
[15246.867897] usb 1-2: New USB device found, idVendor=050d, idProduct=0257
[15246.867897] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[15246.867897] usb 1-2: Product: USB-Serial Controller
[15246.867897] usb 1-2: Manufacturer: Prolific Technology Inc.

my lsusb output is
Bus 001 Device 012: ID 050d:0257 Belkin Components F5U257 Serial

I want to code to send and recieve data can anyone please help me.
 
Old 08-09-2010, 08:14 AM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
cadd,
Please explain in detail what you are trying to accomplish. Your device seems to be recognized so I assume it is just a matter of writing some program to communicate with your device.
 
Old 08-10-2010, 11:46 AM   #8
Elemecca
Member
 
Registered: Nov 2008
Location: San Francisco, CA
Distribution: Gentoo, CentOS
Posts: 71

Rep: Reputation: 22
cadd, it looks like you have a Belkin USB to RS-232 adapter plugged in, which uses the Prolific PL-2303 chipset. It's been recognized by the pl2303 driver, which is exposing it as the TTY device /dev/ttyUSB0. It's a plain old TTY, so you can treat it just like a normal serial terminal and ignore the USB part entirely. USB is being handled for you by the kernel.

If you just want to send a data file across the wire and no special protocol is required, you may be able to do so with shell IO redirection. For example:
Code:
$ cat my-data-file > /dev/ttyUSB0
If you want to interact with it like a normal terminal you need a terminal emulator like minicom.

If you want to write a C application that interacts with it to do something other than emulate a terminal to the user, then you'll need to use the POSIX termios interface. There's a wealth of information about it online, including:
Wikibooks: Serial Programming
TLDP Serial Programming HOWTO (already posted by michaelk)
POSIX.1-2004 XBD Ch. 11: General Terminal Interface (the POSIX spec)
 
Old 09-09-2010, 08:57 AM   #9
cadd
LQ Newbie
 
Registered: Aug 2010
Posts: 16

Rep: Reputation: 0
Thanks Elemecca for detailed reply.

I am doing it as a serial communication only in C under linux. I have a specific protocol to follow. I am very new to serial port communication. You have suggested 3 methods for programming through C for specific protocol. which one do you think is best.

I am also trying to use minicom to see how is the dumb device doing as I have no clue what it is taking and giving me as output. How can I do it in minicom. I have minicom working on my machine but do not know how to send data to my serial port and read data using minicom.

thanks.


Cadd
 
Old 12-21-2022, 06:22 AM   #10
khanma
LQ Newbie
 
Registered: Dec 2022
Posts: 1

Rep: Reputation: 0
Minicom

Hi CADD
I am new to LQ as well as minicom. I have connected my serial device through USB to RS232 converter and it is showing the USB device as online status. Now i want to check if i can send and receive some data on my controller (roboclaw)? Is it possible to check transmitted and receiving data on minicom?

Thanks
Meeran Ali
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
utility allows terminal communication over serial ports zillah Solaris / OpenSolaris 1 11-11-2005 02:05 AM
serial port communication prems Linux - Newbie 1 04-17-2005 02:31 AM
Serial port communication in 'C' on Linux kirti Linux - Hardware 1 06-25-2004 01:58 PM
communication with serial port vidyaraj Linux - Hardware 0 03-09-2004 08:32 PM
serial port communication vidyaraj Linux - Software 6 03-02-2004 06:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration