LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-28-2009, 12:54 AM   #1
clarksa
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
Linux PC Talking to Self out COM1 and in COM2


Can I make a program to transmit data out one serial port and recieve it through another using RS-232? I'm on ubuntu in case something's broken that I don't know about. I need to interface an FPGA to user software for a school project and I've never done anything like this before.

Do I use a null-modem cable? What libraries do I need for serial? Is the API part of the kernel? Can anyone recommend any guides?

If you're interested the project is for robotic simulations using player/stage. We'll be testing parallel processing algorithms on the FPGA to process environment data and control a virtual robot. I've chosen RS-232 for the relative programming simplicity over say USB as I've got a firm deadline to produce a demo (months away mind you but school takes up a lot of my time). In any case if this were possible I could learn serial communication and also have the software interface basically taken care of while I wait for the dev kit hardware.
 
Old 10-28-2009, 01:36 AM   #2
CoderMan
Member
 
Registered: Jan 2009
Location: Gemini Capsule 25164
Distribution: Gentoo
Posts: 375
Blog Entries: 24

Rep: Reputation: 43
Quote:
Originally Posted by clarksa View Post
Can I make a program to transmit data out one serial port and recieve it through another using RS-232? I'm on ubuntu in case something's broken that I don't know about. I need to interface an FPGA to user software for a school project and I've never done anything like this before.

Do I use a null-modem cable? What libraries do I need for serial? Is the API part of the kernel? Can anyone recommend any guides?

If you're interested the project is for robotic simulations using player/stage. We'll be testing parallel processing algorithms on the FPGA to process environment data and control a virtual robot. I've chosen RS-232 for the relative programming simplicity over say USB as I've got a firm deadline to produce a demo (months away mind you but school takes up a lot of my time). In any case if this were possible I could learn serial communication and also have the software interface basically taken care of while I wait for the dev kit hardware.
I'm no expert, but the most helpful guide I've found to Linux serial programming is this one:

http://www.easysw.com/~mike/serial/serial.html

This is for C programming, of course. I spent about an hour working with it and I was able to do basic serial configuration and read/write. It gives an explanation of the null-modem cable issue also.
 
Old 10-28-2009, 10:03 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
With both ports on a single host, all you need are two conductors: each port's Tx pin connected to the other port's Rx pin. No ground necessary for a one-host system.

Some other good links, in addition to the very good one pointed out by CoderMan:

Serial Howto
Serial Programming Howto
Terminal Concepts in GNU/Linux
C-Kermit

These links should give you everything you need, including some very good examples to get you started. I recommend starting with a couple of terminal emulator sessions, such as minicom or C-Kermit (my preferred tool), just to sort out the cabling, port names, etc. Then replace one end of the connection with some of your own code. Once you have the basic communications working, flesh out the project with your own software.

--- rod.
 
Old 10-28-2009, 11:30 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
I think I'm missing something.

Why do you want to send on one port and receive on another port; can't you do both on the same port?
 
Old 10-28-2009, 01:20 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I would imagine he is writing code to communicate with some device, as well as creating a software simulator of that device. Each end of the system is a talker and a listener, and performs different functions, independently of the other. I have done this myself at times, and it worked very well as a first level of testing and debugging tool. Very useful when the target hardware is unavailable as a test & development platform.
--- rod.
 
  


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
connecting com2 (c++) yony Programming 2 12-20-2005 05:55 AM
URGENT call to old school guys: Transfer a file from linux to Win95 via com1 or lpt1? khermans Linux - Networking 12 04-17-2005 05:23 PM
Using COM1 on a RedHat9.0 Linux sys. to connect to an SGI SGIXS Linux - General 1 08-22-2003 06:42 PM
COM1 port in linux? cav Linux - Hardware 1 02-16-2003 02:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:59 AM.

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