HPlogo DTC Device File Access Utilities and Telnet Port Identification: HP 9000 Computers > Chapter 5 Application Examples

Accessing DTC or non-DTC Ports Programmatically

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

Programs that communicate with devices on a MUX use the tty names defined in the /dev directory. Programmatic access to DTC or non-DTC server ports relies upon using outgoing dedicated ports. which are defined in the dp file, and have an ocd process running for that port. Then the standard HP-UX calls read(), write(), open(), close(), and ioctl() can be used.

When using the open() call, the name of the device file for the path parameter should be a pseudonym defined in the dp file. When the open() executes, the outbound connection daemon, ocd, initiates a connection to the server port specified in the dp file. Then, read and write calls to the device can begin.

Here is a sample application for outgoing connections:

#include <errno.h>
#include <stdio.h>
#include <sys/fcntl.h>
#include <sys/ptyio.h>
#include <sys/ioctl.h>
#include <sys/termio.h>

main()
{
char msg [ 80] ;
char i;
int fd;
if ( ( fd = open ( "/dev/telnet/dtcb1p4", O_RDWR ) ) == -1 ) {
printf ( "Unable to open device file: error %d: %s\\n",
errno, strerror ( errno ) );
exit ( 1 );
}
for ( i = 0; i <= 'z' - 'a'; i++ ) {
sprintf ( msg, "Character %1d is %c\\n", i + 1, 'a' + i );
write ( fd, msg, strlen ( msg ) );
}
if ( ioctl ( fd, TCSBRK, 0 ) == -1 ) {
printf ( "Unable to send break to device: error %d: %s\\n",
errno, strerror ( errno ) );
exit ( 1 );
}
if ( close ( fd ) == -1 ) {
printf ( "Unable to close device file\\n" );
exit ( 1 );
}
exit ( 0 );
}

Use of the ioctl() call and the TERMIO structure is limited to actions which are supported by the terminal server hardware and which are allowed over a networked connection.

NOTE: The main TERMIO restrictions include modem signal control and parity checking.

Refer to the ddfa manual reference page for more details on ioctl and TERMIO limitations. Refer to the termio manual reference page for details on terminal input/output, ioctl, and TERMIO structures.

© 1995 Hewlett-Packard Development Company, L.P.