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 06-04-2007, 01:07 AM   #1
amit_pansuria
Member
 
Registered: Sep 2006
Posts: 73

Rep: Reputation: 15
how to write appication of LAN to serial device


helo i m using fedora core -6
i wan tto write application on the LAN to serial device and using then
want to trasfer data(text messages, files etc)
can u give me some tips how to write such application.
my setup is given below

There is one server pc and there are 30 modems each has RS-232 interface.
now there is a LAN to serial device in b/w pc and modems

Regards,
Amit
 
Old 06-04-2007, 04:45 AM   #2
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
To get it clear:
you have a server PC and 30 modems connected to it on RS232
you want to send data from another PC to the modem(s)

If so, you need to write 2 applications. A server app that receives data from the other PC and sends the data to a specified modem and a client app that sends the data to the server PC.
Before you can start coding,

1)
You need to define a protocol (command set and replies) for the communication between the client and the server. Below some simple examples
Code:
command: txt modemnumber textstring
reply  : txt modemnumber status

command: file modemnumber length databytes
reply  : file modemnumber status
What should happen:
When the server receives the complete txt command, it will send the textstring to the specified modem. After this, the server will reply to the client with a status, e.g
>=0 for OK (the number indicates the number of bytes send to the modem)
-1 unknown command
-2 incorrect command format
-3 no reply from modem
-4 other error

It's up to you if the protocol is binary based (where commands and modemnumber are integers) or ascii based (where the command and modemnumber are transmitted as text). The underlaying code will be the same (a byte is a byte, regardless if it's a ascii character or an e.g 8-bit integer).

Ascii is slightly easier to start with as you can start of with telnet on the client PC and concentrate on the server side.

Please note that the given examples are simple. You can add error checking (e.g a CRC of the message) as well or break files into pieces.

2)
You also have to decide if you're going to use UDP or TCP; it depends on your application which one you can use. TCP guarantees that packets are received by the receiver (or you will receive an error message). If you use UDP, you might have to implement some additional checks if you want to make sure that packets have arrived.

With the UDP you can not use telnet for testing.
 
Old 06-04-2007, 11:04 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
Wim Sturkenboom is correct about the division between server and client elements of the problem.

You need to know more about the nature of the distant hosts to which the modems will connect. Until you know and provide this information, any answer that anyone can provide is pure speculation. In other words, when your program dials out to connect to another host, what will that host be? Is it a Unix-like system expecting a login? Is it some special server application expecting some proprietary communication format? Is it an interactive session of some sort? Is it a PPP/SLIP server? Is that end of the communication protocol undefined, and up to you to produce? What? The answer to this is fundamental to the problem. In fact, you have not stated whether the modems are to be considered to be permanently connected, or whether your program needs to dial out.

I another thread, you have already been given pointers to two very good HOWTO's related to comunicating with serial devices (your modems). Have you written or attempted to write any code that talks to your modem?

Do you have an existing driver that supports your 30 port serial interface? Is it working? Have you tried using an existing serial communications application such as minicom or C-Kermit with your serial interface? If the serial interface driver is not working, you will need to either fix it, or you will need to write your own driver. What is the make & model description of the hardware?

Please answer these questions before repeating your general question yet again. People are trying to help you. Please do them and yourself the service of supplying the information required to provide useful answers.
--- rod.

Last edited by theNbomr; 06-04-2007 at 11:05 AM.
 
  


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
Problem to write to serial port os2 Programming 8 08-23-2016 02:48 AM
Should be dead simple - read/write serial port from bash ericcarlson Linux - Software 3 10-21-2006 08:35 PM
USB device as serial device BlackHatRob Linux - Hardware 1 06-08-2006 07:09 PM
How do i write to a serial port (modem) in ascii or hex directly? Taliesin.duchaos Linux - Networking 6 04-21-2006 08:31 AM
Serial port Read Write SeanatIL Programming 2 07-14-2004 03:42 PM

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

All times are GMT -5. The time now is 07:52 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