Sponsored Content
Top Forums Programming How to read the CTS and DSR of RS232 in Unix using C language? Post 44372 by Perderabo on Friday 5th of December 2003 02:03:53 AM
Old 12-05-2003
Please click on the rules link at the bottom of the page. I have deleted your other thread.

You're not going to be able to do what you want. Use the command "man termios" to see what is available from the terminal driver. Use our search function to searc this forum to see some examples of termios in use.

In you have the hardware, you can use modem control signals, but the driver does it on your behalf. For an incoming line, a open() call raises DTR which signals the modem that it may auto-answer a call. When it does, it will raise DSR which causes the open to complete. If DSR drops, a hup signal is generated. A very clever program might be able to use all of this to "read" the state of the DSR signal. But open() is an expensive system call and the bandwidth would be low.

Some unix systems (maybe most? or all?) you can use CTS for hardware flow control of output, and RTS for hardware flow control of input. There is no hope for RTS, but a clever program might be able to determine the state of CTS by seeing if a non-blocking write() succeeds. But DSR would need to be high.

You might be able to have a simple switch send a break character. Anyone who uses a Sun with a terminal console knows how easy that is. You can arrange for a break character to send an INT signal to the program.
 

10 More Discussions You Might Find Interesting

1. Programming

RS232 communication optimisation

Need help for RS232 communication with switches in order to optimise the data traffic. How to manipulate different flags in termios struct to do the same? (1 Reply)
Discussion started by: ManishSaxena
1 Replies

2. UNIX for Advanced & Expert Users

VNC via Rs232

Hi ! Is there somebody who is able to connect a VNC session via serial cable ? There is a hint on the VNC homepage that it is possible to configure that. But how? thanks joerg (2 Replies)
Discussion started by: joerg
2 Replies

3. Solaris

rs232 pci-card

hello mates, do you know a manufactor for rs232 serial pci cards for the sparc architecture? it seems that there is no original product from sun for that purpose. strange, isn't it? problem is that i have a V250 with only one db9 rs232 serial port, and i need it for a modem connection, but i also... (1 Reply)
Discussion started by: pressy
1 Replies

4. Programming

How to set the DSR pin using a C Code

Hi, I am a newbie using linux. I want to use the 9 pins of the COM port for data transmission. I am trying to write a code to toggle the DTR pin in /dev/ttyS0. Can any one help by giving a sample code or links that will help me pick up fast Regards (2 Replies)
Discussion started by: Srikanthks_2000
2 Replies

5. UNIX for Dummies Questions & Answers

Can A File Be Copied to an RS232 Port on Unix?

We have a text/csv file (4mb) sitting on a Unix box. The PC belongs to a retail store and they're asking me to bring the file over to Windows so they can import the file. Can a file be copied to an rs232 port? If so how? The idea is that I'll hook up a null modem cable to the Unix com port,... (2 Replies)
Discussion started by: alivebyscience
2 Replies

6. Programming

Help to filter read through reference file by using c language

Input_file #tmp_2 werweraewghe @tmp_2 123sdfs57a #tmp_1 aewrgheheghe @tmp_1 457awrerfa87 #tmp_4 trtyrghe @tmp_4 8898rtyr2 reference_file #tmp_4 #tmp_1 (14 Replies)
Discussion started by: cpp_beginner
14 Replies

7. Programming

regarding adding fields to DSR protocol in ns2.34

hi i am student doing project in ns2.34. i hav to add field in route cache and packet of DSR routing protocol. which files hv to be changed...pl help me (1 Reply)
Discussion started by: khubalkar
1 Replies

8. Homework & Coursework Questions

regarding adding fields to DSR protocol in ns2.34

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: want to add field to route cache and packet of DSR routing protocol in ns2.34, add field, DSR package in ns2.34... (2 Replies)
Discussion started by: khubalkar
2 Replies

9. IP Networking

How to configure RHEL6 to support Aleton 4408 in DSR mode?

Dears How to configure RHEL6 to support Aleton 4408 in DSR(Direct Server Return) mode We have config Aleton 4408 + Windows 2008R2 then Windows set loopback interface with VIP. the exec the following command in CMD netsh interface ipv4 set interface "net" weakhostreceive=enabled netsh... (0 Replies)
Discussion started by: nnnnnnine
0 Replies

10. IP Networking

Source IP address field in RREP on DSR routing

Hello I have a question about routing in MANET using Dynamic Source Routing protocol. IN RFC4728 (DSR) in section "IP fields" of RREP (Route Reply) packet we have this: ok. I read in several books and also in rfc4728 that: when a source node (node that initiate route discovery process)... (1 Reply)
Discussion started by: acu281
1 Replies
zs(7D)                                                                Devices                                                               zs(7D)

NAME
zs - Zilog 8530 SCC serial communications driver SYNOPSIS
#include <fcntl.h> #include <sys/termios.h> open("/dev/term/n", mode); open("/dev/ttyn", mode); open("/dev/cua/n", mode); DESCRIPTION
The Zilog 8530 provides two serial input/output channels capable of supporting a variety of communication protocols. A typical system uses two or more of these devices to implement essential functions, including RS-423 ports (which also support most RS-232 equipment), and the console keyboard and mouse devices. The zs module is a loadable STREAMS driver that provides basic support for the Zilog 8530 hardware and basic asynchronous communication support. The driver supports the termio(7I) device control functions specified by flags in the c_cflag word of the termios structure and by the IGNBRK, IGNPAR, PARMRK, or INPCK flags in the c_iflag word. All other termio(7I) functions must be performed by STREAMS modules pushed atop the driver. When a device is opened, the ldterm(7M) and ttcompat(7M) STREAMS modules are automatically pushed on top of the stream, providing the standard termio( 7I) interface. The character-special devices /dev/term/a and /dev/term/b are used to access the two serial ports on the CPU board. Valid name space entries are /dev/cua/[a-z], /dev/term/[a-z] and /dev/tty[a-z]. The number of entries used in a name space are machine dependent. The /dev/tty[n] device names only exist if the SunOS 4.x Binary Compatibility Package is installed. The /dev/tty[n] device names are cre- ated by the ucblinks command, which is available only with the SunOS 4.x Binary Compatibility Package. To allow a single tty line to be connected to a modem and used for both incoming and outgoing calls, a special feature is available that is controlled by the minor device number. By accessing character-special devices with names of the form /dev/cua/[n], it is possible to open a port without the Carrier Detect signal being asserted, either through hardware or an equivalent software mechanism. These devices are commonly known as dial-out lines. Once a /dev/cua/[n] line is opened, the corresponding tty line cannot be opened until the /dev/cua/n line is closed. A blocking open will wait until the /dev/cua/[n] line is closed (which will drop Data Terminal Ready, and Carrier Detect) and carrier is detected again. A non- blocking open will return an error. If the tty line has been opened successfully (usually only when carrier is recognized on the modem) , the corresponding /dev/cua/[n] line cannot be opened. This allows a modem to be attached to /dev/term/[n] (renamed from /dev/tty[n]) and used for dial-in (by enabling the line for login in /etc/inittab) and also used for dial-out (by tip(1) or uucp(1C)) as /dev/cua/[n] when no one is logged in on the line. Note - This module is affected by the setting of specific eeprom variables. For information on parameters that are persistent across reboots, see the eeprom(1M) man page. IOCTLS
The zs module supports the standard set of termio ioctl() calls. If the CRTSCTS flag in the c_cflag field is set, output will be generated only if CTS is high; if CTS is low, output will be frozen. If the CRTSCTS flag is clear, the state of CTS has no effect. If the CRTSXOFF flag in the c_cflag field is set, input will be received only if RTS is high; if RTS is low, input will be frozen. If the CRTSXOFF flag is clear, the state of RTS has no effect. The termios CRTSCTS (respectively CRTSXOFF) flag and termiox CTSXON (respectively RTSXOFF) can be used interchangeably. Breaks can be generated by the TCSBRK, TIOCSBRK, and TIOCCBRK ioctl() calls. The state of the DCD, CTS, RTS, and DTR interface signals may be queried through the use of the TIOCM_CAR, TIOCM_CTS, TIOCM_RTS, and TIOCM_DTR arguments to the TIOCMGET ioctl command, respectively. Due to hardware limitations, only the RTS and DTR signals may be set through their respective arguments to the TIOCMSET, TIOCMBIS, and TIOCMBIC ioctl commands. The input and output line speeds may be set to any of the speeds supported by termio. The input and output line speeds cannot be set inde- pendently; for example, when you set the the output speed, the input speed is automatically set to the same speed. When the driver is used to service the serial console port, it supports a BREAK condition that allows the system to enter the debugger or the monitor. The BREAK condition is generated by hardware and it is usually enabled by default. A BREAK condition originating from erro- neous electrical signals cannot be distinguished from one deliberately sent by remote DCE. The Alternate Break sequence can be used to rem- edy this. Due to a risk of incorrect sequence interpretation, SLIP and certain other binary protocols should not be run over the serial console port when Alternate Break sequence is in effect. Although PPP is a binary protocol, it is able to avoid these sequences using the ACCM feature in RFC 1662. For Solaris PPP 4.0, you do this by adding the following line to the /etc/ppp/options file (or other configuration files used for the connection; see pppd(1M) for details): asyncmap 0x00002000 By default, the Alternate Break sequence is three characters: carriage return, tilde and control-B (CR ~ CTRL-B), but may be changed by the driver. For more information on breaking (entering the debugger or monitor), see kbd(1) and kb(7M). ERRORS
An open will fail under the following conditions: ENXIO The unit being opened does not exist. EBUSY The dial-out device is being opened and the dial-in device is already open, or the dial-in device is being opened with a no-delay open and the dial-out device is already open. EBUSY The port is in use by another serial protocol. EBUSY The unit has been marked as exclusive-use by another process with a TIOCEXCL ioctl() call. EINTR The open was interrupted by the delivery of a signal. FILES
/dev/cua/[a-z] dial-out tty lines /dev/term/[a-z] dial-in tty lines /dev/tty[a-z] binary compatibility package device names ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |SPARC | +-----------------------------+-----------------------------+ SEE ALSO
eeprom(1M), kadb(1M), tip(1), ucblinks(1B), cu(1C), uucp(1C), ports(1M), pppd(1M), ioctl(2), open(2), attributes(5), zsh(7D), termio(7I), kb(7M), ldterm(7M), ttcompat(7M) DIAGNOSTICS
zsn: silo overflow. The Zilog 8530 character input silo overflowed before it could be serviced. zsn: ring buffer overflow. The driver's character input ring buffer overflowed before it could be serviced. SunOS 5.10 9 Sep 2002 zs(7D)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy