programming serial port

This is a discussion on programming serial port within the Linux Networking forums, part of the Linux Forums category; Hello, I have to establishe communication between 2 PC with modems. The remote PC works under windows 98 and sends ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-18-2003
Carmin
 
Posts: n/a
Default programming serial port

Hello,



I have to establishe communication between 2 PC with modems. The remote PC
works under windows 98 and sends data buffer or file to my local PC wich is
under linux redhat. I am beginner with linux and my question is to know if
it is possible to manage the reception of data only writing a script. Or I
have to write a C program using the termios structure to configure serial
port and open, read, write functions. What is the best way for my work?



I thank you for your answers and excuse-me for my bad english.


Reply With Quote
  #2 (permalink)  
Old 11-18-2003
Frank da Cruz
 
Posts: n/a
Default Re: programming serial port

In article <bpdjo9$2sm$1@news-reader2.wanadoo.fr>, Carmin wrote:
: I have to establishe communication between 2 PC with modems. The remote PC
: works under windows 98 and sends data buffer or file to my local PC wich is
: under linux redhat. I am beginner with linux and my question is to know if
: it is possible to manage the reception of data only writing a script. Or I
: have to write a C program using the termios structure to configure serial
: port and open, read, write functions. What is the best way for my work?
:
Yes, you can do it with a Kermit script:

http://www.columbia.edu/kermit/ckermit.html C-Kermit for Linux
http://www.columbia.edu/kermit/k95.html Kermit 95 for Windows
http://www.columbia.edu/kermit/ckscripts.html Scripting tutorial


- Frank
Reply With Quote
  #3 (permalink)  
Old 11-19-2003
David Efflandt
 
Posts: n/a
Default Re: programming serial port

On Tue, 18 Nov 2003 18:08:16 +0100, Carmin <carmin.gam@wanadoo.fr> wrote:
> Hello,
>
> I have to establishe communication between 2 PC with modems. The remote PC
> works under windows 98 and sends data buffer or file to my local PC wich is
> under linux redhat. I am beginner with linux and my question is to know if
> it is possible to manage the reception of data only writing a script. Or I
> have to write a C program using the termios structure to configure serial
> port and open, read, write functions. What is the best way for my work?


If you know how to Perl script, you might look for Device::SerialPort
module on a CPAN mirror. It is a Unix (Linux) version of Win32::Serial
port.

--
David Efflandt - All spam ignored http://www.de-srv.com/
Reply With Quote
  #4 (permalink)  
Old 11-19-2003
Grant Edwards
 
Posts: n/a
Default Re: programming serial port

In article <bpdjo9$2sm$1@news-reader2.wanadoo.fr>, Carmin wrote:

> I have to establishe communication between 2 PC with modems. The remote PC
> works under windows 98 and sends data buffer or file to my local PC wich is
> under linux redhat. I am beginner with linux and my question is to know if
> it is possible to manage the reception of data only writing a script.


Sure. Use Kermit like Frank suggested, or use Bash and sz/rz
commands to transfer files using xmodem/ymodem/zmodem
protocols. If you really want to go old-school, you could set
up uucp -- if you've got a whole dial-up network, uucp still
rocks.

> Or I
> have to write a C program using the termios structure to configure serial
> port and open, read, write functions. What is the best way for my work?


If you decide to write a program, for god's sake don't use C --
you're not write a kernel module. Use a high-level language
like Python or Perl (gack!)

--
Grant Edwards grante Yow! I've read SEVEN
at MILLION books!!
visi.com
Reply With Quote
  #5 (permalink)  
Old 11-19-2003
Alan Connor
 
Posts: n/a
Default Re: programming serial port

On 19 Nov 2003 04:27:21 GMT, Grant Edwards <grante@visi.com> wrote:
>
>
> In article <bpdjo9$2sm$1@news-reader2.wanadoo.fr>, Carmin wrote:
>
>> I have to establishe communication between 2 PC with modems. The remote PC
>> works under windows 98 and sends data buffer or file to my local PC wich is
>> under linux redhat. I am beginner with linux and my question is to know if
>> it is possible to manage the reception of data only writing a script.

>
> Sure. Use Kermit like Frank suggested, or use Bash and sz/rz
> commands to transfer files using xmodem/ymodem/zmodem
> protocols. If you really want to go old-school, you could set
> up uucp -- if you've got a whole dial-up network, uucp still
> rocks.


minicom can do zmodem stuff.
and the tool for zmodem on posix computers is lrzsz.

>
>> Or I
>> have to write a C program using the termios structure to configure serial
>> port and open, read, write functions. What is the best way for my work?

>
> If you decide to write a program, for god's sake don't use C --
> you're not write a kernel module. Use a high-level language
> like Python or Perl (gack!)


Beg to differ. C is much more versatile and efficient. Why would someone
want to be limited by P&P? They only SEEM easier. In the long run they
are harder.

AC
Reply With Quote
  #6 (permalink)  
Old 11-19-2003
Floyd Davidson
 
Posts: n/a
Default Re: programming serial port

Alan Connor <zzzzzz@xxx.yyy> wrote:
>On 19 Nov 2003 04:27:21 GMT, Grant Edwards <grante@visi.com> wrote:
>>
>> If you decide to write a program, for god's sake don't use C --
>> you're not write a kernel module. Use a high-level language
>> like Python or Perl (gack!)


As always, Grant provides some excellent advice based on a very
good understanding of the context.

>Beg to differ. C is much more versatile and efficient. Why would someone
>want to be limited by P&P? They only SEEM easier. In the long run they
>are harder.


As always, Alan Connor hasn't got a clue. But, I thought it
would be just perfect to quote from an article that Alan posted
to comp.lang.c a few hours back, because it does put this in a
proper perspective. (Not to mention it's good for a laugh, as
our resident expert gives us a great demonstration of how
"versatile and efficient" C programming is!)

Newsgroups: comp.lang.c
From: Alan Connor <zzzzzz@xxx.yyy>
Subject: EOF (novice)
Message-ID: <Fizub.5196$sb4.479@newsread2.news.pas.earthlink.n et>
Date: Wed, 19 Nov 2003 01:02:29 GMT

From K&R:

#include <stdio.h>

main()

/* copy input to output */

{
int c;

c = getchar();
while (c != EOF) {

putchar(c);
c = getchar();

}

}


If I am reading the text correctly, this program should
terminate when I enter -1 (EOF as defined on my system,
Linux).

But it doesn't. Just keeps right on trucking.

What gives?

AC

--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@barrow.com
Reply With Quote
  #7 (permalink)  
Old 11-19-2003
Alan Connor
 
Posts: n/a
Default Re: programming serial port

On Tue, 18 Nov 2003 22:19:28 -0900, Floyd Davidson <floyd@barrow.com> wrote:

Well Floyd, you can libel me until the cows come home. Knock yourself
out.

But I am NOT going to exchange those kinds of pictures with you, and if
you send me any more, they are going to the police.

AC

Reply With Quote
  #8 (permalink)  
Old 11-19-2003
Floyd Davidson
 
Posts: n/a
Default Re: programming serial port

Alan Connor <zzzzzz@xxx.yyy> wrote:
>On Tue, 18 Nov 2003 22:19:28 -0900, Floyd Davidson <floyd@barrow.com> wrote:
>
>Well Floyd, you can libel me until the cows come home. Knock yourself
>out.
>
>But I am NOT going to exchange those kinds of pictures with you, and if
>you send me any more, they are going to the police.
>
>AC


And now you're over there in c.l.c discussing an *excellent*
program example, from K&R, saying

"You are missing my point: The program as written in K&R
*doesn't work*. Or it seems not to.

That part of the book is POORLY WRITTEN. Lame."

And here you are in this group giving out advice on which
programming languages are best for one particular use. Tsch
tsch, as if you had half a clue.

And your only response to me is to claim that your email that I
bounced back to you incriminates someone other than you...

--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@barrow.com
Reply With Quote
  #9 (permalink)  
Old 11-19-2003
Leon.
 
Posts: n/a
Default Re: programming serial port


"Carmin" <carmin.gam@wanadoo.fr> wrote in message
news:bpdjo9$2sm$1@news-reader2.wanadoo.fr...
> Hello,
>
>
> I have to establishe communication between 2 PC with modems. The remote PC
> works under windows 98 and sends data buffer or file to my local PC wich

is
> under linux redhat. I am beginner with linux and my question is to know if
> it is possible to manage the reception of data only writing a script.



Sounds like you are going to have to build a complicated 'state machine'.

One end has to verify which state the other is in and decide what state to
move to next, and verify it got there.



> Or I
> have to write a C program using the termios structure to configure serial
> port


You can use "stty" to do all this from a script.

Also there is the program "expect" that has the ability to detect various
strings and has a timeout.
So you can write the equivalent of a "send and expect " script.. and recover
from faults.
This saves work under C.





> and open, read, write functions. What is the best way for my work?


That does depend how much programming you need to do , and what libraries
you need to use.

It can be painful to do things in the shell, because of its inability to
handle characters. and lack of simple functions -its got all the standard
utils to use, but they arent low level things, they are high level.

Perl can handle characters better, and has many low level functions ready to
use.
As its only handling a serial line, perl will run fast enough for the job.






>
>
>
> I thank you for your answers and excuse-me for my bad english.
>
>



Reply With Quote
  #10 (permalink)  
Old 11-19-2003
Grant Edwards
 
Posts: n/a
Default Re: programming serial port

In article <BkGub.6763$n56.3796@newsread1.news.pas.earthlink. net>, Alan Connor wrote:

> But I am NOT going to exchange those kinds of pictures with you, and if you
> send me any more, they are going to the police.


Well, if there was any doubt about whether Mr. Conner's were worth the bits
they were printed on, that certainly clinched it.

--
Grant Edwards grante Yow! Where's th' DAFFY
at DUCK EXHIBIT??
visi.com
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:53 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0