Networking Forums

Networking Forums > Computer Networking > Linux Networking > Serial communication diagnostic application_Linux

Reply
Thread Tools Display Modes

Serial communication diagnostic application_Linux

 
 
Nutty
Guest
Posts: n/a

 
      10-11-2006, 11:15 AM
Hello,

I m beginner in Linux. I m writing the Diagnostic application for the
Serial Port. I m using 16550UART for the serial communication, C
Language for writing the code and the Linux OS.
As a part of the diagnostic i would like to
1. Check Existance of the serial port
2. Check Its BAUD RATE.
3. Modify the BAUD RATE
4. Write to serial port
5. Read from the serial port.

Please let me where can i get the sample code for the same.
I m a new in Linux. In my previous project i was working on Wince for
the same type of Diagnostic.
Also i worked on the Keil Compiler for 89c51rd2. There i was using
MAX232 for the serial communication.

Please guide me...

 
Reply With Quote
 
 
 
 
Lew Pitcher
Guest
Posts: n/a

 
      10-11-2006, 01:12 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nutty wrote:
> Hello,
>
> I m beginner in Linux. I m writing the Diagnostic application for the
> Serial Port.


Your goal contains an apparent contradiction in terms. /Applications/
don't directly access kernel resources like the /serial port/. You are
going to have to clarify your requirements a bit before you will get
any usable assistance here.

Assuming that you are interested in an /application/, then here are a
few hints

> I m using 16550UART for the serial communication, C
> Language for writing the code and the Linux OS.
> As a part of the diagnostic i would like to
> 1. Check Existance of the serial port


To applications, the closest you get to a serial port is the device
file that represents the user interface to the kernel driver for the
device. Serial devices are usually the /dev/tty* devices (/dev/ttyS*
for the true serial devices, IIRC). An application just open(2)s
read(2)s, write(2)s and close(2)s these files to perform it's serial
I/O.

See open(2) ("man 2 open"), read(2) ("man 2 read") write(2) ("man 2
write") and close(2) ("man 2 close") manual pages for details on the
system calls. Also, see ttyS(4) ("man 4 ttyS") for details on the
serial device character special files.


> 2. Check Its BAUD RATE.


You do this through an ioctl(2) call or a termios(3) call on the open()
character special device. See ioctl(2) ("man 2 ioctl") for the
documentation on the ioctl(2) call and tty_ioctl(4) ("man 4 tty_ioctl")
for the documentation on the various IOCTL values. Also see termios(3)
("man 3 termios") for the documentation on the termios(3) call.


> 3. Modify the BAUD RATE


You do this through an ioctl(2) call or a termios(3) call on the
open(2) character special device. See ioctl(2) ("man 2 ioctl") for the
documentation on the ioctl(2) call and tty_ioctl(4) ("man 4 tty_ioctl")
for the documentation on the various IOCTL values. Also see termios(3)
("man 3 termios") for the documentation on the termios(3) call.


> 4. Write to serial port


You do this through a write(2) or formatted write (fprintf(3),
fwrite(3)) call on the open(2) character special device.


> 5. Read from the serial port.


You do this through a read(2) or formatted read (fscanf(3), fread(3))
call on the open(2) character special device.


[snip]

HTH
- --
Lew Pitcher

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32) - WinPT 0.11.12

iD8DBQFFLO2qagVFX4UWr64RAmBsAJ9JoDxP8MFcNOe7t4RBZ3 a+DFqudwCeKE9A
3ssoUhSseeHClfoUaVcFHSY=
=rOKB
-----END PGP SIGNATURE-----

 
Reply With Quote
 
Nutty
Guest
Posts: n/a

 
      10-12-2006, 10:58 AM

Lew Pitcher wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Nutty wrote:
> > Hello,
> >
> > I m beginner in Linux. I m writing the Diagnostic application for the
> > Serial Port.

>
> Your goal contains an apparent contradiction in terms. /Applications/
> don't directly access kernel resources like the /serial port/. You are
> going to have to clarify your requirements a bit before you will get
> any usable assistance here.
>
> Assuming that you are interested in an /application/, then here are a
> few hints
>
> > I m using 16550UART for the serial communication, C
> > Language for writing the code and the Linux OS.
> > As a part of the diagnostic i would like to
> > 1. Check Existance of the serial port

>
> To applications, the closest you get to a serial port is the device
> file that represents the user interface to the kernel driver for the
> device. Serial devices are usually the /dev/tty* devices (/dev/ttyS*
> for the true serial devices, IIRC). An application just open(2)s
> read(2)s, write(2)s and close(2)s these files to perform it's serial
> I/O.
>
> See open(2) ("man 2 open"), read(2) ("man 2 read") write(2) ("man 2
> write") and close(2) ("man 2 close") manual pages for details on the
> system calls. Also, see ttyS(4) ("man 4 ttyS") for details on the
> serial device character special files.
>
>
> > 2. Check Its BAUD RATE.

>
> You do this through an ioctl(2) call or a termios(3) call on the open()
> character special device. See ioctl(2) ("man 2 ioctl") for the
> documentation on the ioctl(2) call and tty_ioctl(4) ("man 4 tty_ioctl")
> for the documentation on the various IOCTL values. Also see termios(3)
> ("man 3 termios") for the documentation on the termios(3) call.
>
>
> > 3. Modify the BAUD RATE

>
> You do this through an ioctl(2) call or a termios(3) call on the
> open(2) character special device. See ioctl(2) ("man 2 ioctl") for the
> documentation on the ioctl(2) call and tty_ioctl(4) ("man 4 tty_ioctl")
> for the documentation on the various IOCTL values. Also see termios(3)
> ("man 3 termios") for the documentation on the termios(3) call.
>
>
> > 4. Write to serial port

>
> You do this through a write(2) or formatted write (fprintf(3),
> fwrite(3)) call on the open(2) character special device.
>
>
> > 5. Read from the serial port.

>
> You do this through a read(2) or formatted read (fscanf(3), fread(3))
> call on the open(2) character special device.
>
>
> [snip]
>
> HTH
> - --
> Lew Pitcher
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (MingW32) - WinPT 0.11.12
>
> iD8DBQFFLO2qagVFX4UWr64RAmBsAJ9JoDxP8MFcNOe7t4RBZ3 a+DFqudwCeKE9A
> 3ssoUhSseeHClfoUaVcFHSY=
> =rOKB
> -----END PGP SIGNATURE-----




Hello Lew Pitcher,

Thanks a lot for ue kind reply.

Please let me know form where can i gt the information above ,like u
told
> See open(2) ("man 2 open"), read(2) ("man 2 read") write(2) ("man 2
> write") and close(2) ("man 2 close") manual pages for details on the
> system calls. Also, see ttyS(4) ("man 4 ttyS") for details on the
> serial device character special files.


Where to find the details on the system call.

Please guide me..

Thanks and Regards,
Nutty

 
Reply With Quote
 
Lew Pitcher
Guest
Posts: n/a

 
      10-12-2006, 12:02 PM

Nutty wrote:
> Lew Pitcher wrote:
> > Nutty wrote:
> > > Hello,
> > >
> > > I m beginner in Linux. I m writing the Diagnostic application for the
> > > Serial Port.

[snip]
> Hello Lew Pitcher,
>
> Thanks a lot for ue kind reply.
>
> Please let me know form where can i gt the information above ,like u
> told
> > See open(2) ("man 2 open"), read(2) ("man 2 read") write(2) ("man 2
> > write") and close(2) ("man 2 close") manual pages for details on the
> > system calls. Also, see ttyS(4) ("man 4 ttyS") for details on the
> > serial device character special files.

>
> Where to find the details on the system call.


open an xterm
at the prompt, type
man 2 open
read

do the same for each of the other system calls you want to research

 
Reply With Quote
 
David M
Guest
Posts: n/a

 
      10-14-2006, 01:28 AM
On Wed, 11 Oct 2006 04:15:40 -0700, Nutty rearranged some electrons to
form:

> Hello,
>
> I m beginner in Linux. I m writing the Diagnostic application for the
> Serial Port. I m using 16550UART for the serial communication, C
> Language for writing the code and the Linux OS.
> As a part of the diagnostic i would like to
> 1. Check Existance of the serial port
> 2. Check Its BAUD RATE.
> 3. Modify the BAUD RATE
> 4. Write to serial port
> 5. Read from the serial port.
>
> Please let me where can i get the sample code for the same.
> I m a new in Linux. In my previous project i was working on Wince for
> the same type of Diagnostic.
> Also i worked on the Keil Compiler for 89c51rd2. There i was using
> MAX232 for the serial communication.
>
> Please guide me...


http://tldp.org/HOWTO/Serial-HOWTO.html
http://tldp.org/HOWTO/Serial-Programming-HOWTO/

--
David M (dmacchiarolo)
http://home.triad.rr.com/redsled
T/S 53
sled351 Linux 2.4.18-14 has been up 16 days 9:30

 
Reply With Quote
 
 
 
Reply

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial communication frances.albanese@gmail.com Linux Networking 4 03-14-2008 04:21 PM
Minicom serial communication Xilinx board Kristof Loots Linux Networking 0 01-17-2005 01:49 PM
serial port communication Pilatus Linux Networking 4 11-10-2003 02:44 PM
modem is required for serial communication? Matthew Louden Windows Networking 4 10-06-2003 09:05 AM
modem is required for serial communication? Matthew Louden Windows Networking 4 10-06-2003 09:05 AM



1 2 3 4 5 6 7 8 9 10 11