Re: serial ports

2007-05-15 Thread Fontana Nicola
On Monday 14 May 2007 20:49, Pavel A. da Mek wrote:
> When I want to use serial ports, shall I write separate code for Windows
> and for Linux, or is there some library function which would allow to do it
> in the platform  independent way?

I hit the same problem in 2004, and I wrote an abstraction layer and 2 
different implementations. Basically, I implemented open(), close(), read() 
and write() using termios.h in linux and the Windows API (CreateFile(), 
ReadFile(), WriteFile() ...) in windows. read() and write() are implemented 
in a blocking way, because I'm used to put all the dialing stuff in a 
separate thread.

If you want, I can send you the relevant code: be carefull, it is a beautiful 
example of bad C C++ mixing.

-- Nicola
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: serial ports

2007-05-15 Thread Andreas Stricker
Pavel A. da Mek wrote:
> When I want to use serial ports, shall I write separate code for Windows and 
> for Linux, or is there some library function which would allow to do it in 
> the platform  independent way? 

I have written portable code for this with timeouts for read and write 
operations.
Because Windows don't know a generic select() like call but use special
SetCommTimeouts() call I don't know if the g_io_* calls works for Serial port
handles.

I recommend the following literature to start with this task.

POSIX
- "Serial Programming Guide for POSIX Operating Systems" 5th Edition by Michael 
R. Sweet
   http://www.easysw.com/~mike/serial/

Windows
- "Windows Serial Port Programming" by Robertson Bayer
   http://www.robbayer.com/files//serial-win.pdf
- "Serial Communication in Win32" by Allen Denver
   http://msdn2.microsoft.com/en-us/library/ms810467.aspx


Cheers, Andy

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: serial ports

2007-05-14 Thread G Hasse
On Tue, May 15, 2007 at 02:46:22AM +0300, Tor Lillqvist wrote:
> John Coppens writes:
>  > If I'm not mistaken (I don't use windows), look at the g_io functions, I
>  > believe they are portable to Windows too. There may be a problem with the
>  > names of the devices (COM1: vs /dev/ttyS0) or so, but that is relatively
>  > easy to solve, I'd say.
> 
> You are too optimistic. How well the g_io functions work with serial
> port devices is quite unclear. Windows is not Unix. Typically you have
> to use specialized API to talk to each kind of device or IPC channel.

Yes! I Agree. A good start to understand serial ports are to
read chapter 18 in "Advanced programming int the Unix Environment",
Richard Stevens, ISBN 0-201-56317-7.

-- 
Göran Hasse


Göran Hasseemail: [EMAIL PROTECTED] Tel: 08-6949270
Raditex AB http://www.raditex.se
Planiavägen 15, 1tr Mob: 070-5530148
131 34  NACKA, SWEDEN OrgNr: 556240-0589
VAT: SE556240058901
--

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: serial ports

2007-05-14 Thread Tor Lillqvist
John Coppens writes:
 > If I'm not mistaken (I don't use windows), look at the g_io functions, I
 > believe they are portable to Windows too. There may be a problem with the
 > names of the devices (COM1: vs /dev/ttyS0) or so, but that is relatively
 > easy to solve, I'd say.

You are too optimistic. How well the g_io functions work with serial
port devices is quite unclear. Windows is not Unix. Typically you have
to use specialized API to talk to each kind of device or IPC channel.

--tml
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: serial ports

2007-05-14 Thread John Coppens
On Mon, 14 May 2007 18:49:02 -
"Pavel A. da Mek" <[EMAIL PROTECTED]> wrote:

> When I want to use serial ports, shall I write separate code for
> Windows and for Linux, or is there some library function which would
> allow to do it in the platform  independent way? 

If I'm not mistaken (I don't use windows), look at the g_io functions, I
believe they are portable to Windows too. There may be a problem with the
names of the devices (COM1: vs /dev/ttyS0) or so, but that is relatively
easy to solve, I'd say.

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: serial ports

2007-05-14 Thread Michael L Torrie
On Mon, 2007-05-14 at 18:49 +, Pavel A. da Mek wrote:
> When I want to use serial ports, shall I write separate code for Windows and 
> for Linux, or is there some library function which would allow to do it in 
> the platform  independent way? 

There's definitely no GTK library calls to support this type of thing,
so you can either maintain separate code for win32 and linux (ifdefs or
something) or find a reliable, third-party library that fits your
technical and licensing requirements.

I have heard that doing any kind of serial port programming on Windows
is very very painful.  On Linux it's easy.


> 
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


serial ports

2007-05-14 Thread Pavel A. da Mek
When I want to use serial ports, shall I write separate code for Windows and 
for Linux, or is there some library function which would allow to do it in 
the platform  independent way? 

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list