The Asynchronous Serial Communications Programmer's Reference Manual
states on page 8-37:
"These calls are not supported for terminals connected via
Telnet/iX. If FCONTROL(26) is issued to a device connected by
Telnet/iX, it will be ignored. If FCONTROL(27) is issued to a
device connected via Telnet/iX the next FREAD posted to the
device will return an error condition, until binary mode is disabled
(FCONTROL(26)). Binary editing should not be used on a
terminal connected via Telnet/iX. The call will return a CCE
condition code but all subsequent reads will return an error until
binary editing is disabled."
-----------------------------------------------------
Ross Scroggs Email: [log in to unmask]
Telamon, Inc. Phone: (510)987-7700x104
492 Ninth Street, Suite 310 Fax: (510)987-7009
Oakland, CA 94607-4098
-----------------------------------------------------
> -----Original Message-----
> From: HP-3000 Systems Discussion [mailto:[log in to unmask]]On
> Behalf Of Ian Collins
> Sent: Monday, August 03, 1998 8:24 PM
> To: [log in to unmask]
> Subject: FREAD on a network device - revisited
>
>
> (Used to be: I/O in MPE 5.5 -FCONTROL and FREAD on a network device)
>
> Following is a small C program - written exclusively for MPE/ix
> This small program works fine if on a hardwired terminal (e.g. MPE
> master console).
> If on a pseudo terminal (e.g, a telnet session), then the FREAD fails
> every time (ie, returns 0 chars read).
>
> HOWEVER, THIS ONLY HAPPENS IF THE CHANNEL IS SET TO "BINARY MODE",
> (FCONTROL 27).
> However, I need to have binary mode set (for input editing, etc).
> Does anyone have any idea how to do this?
>
> Example code starts:
>
> /* --- snip --- */
> #include <stdio.h>
> #pragma INTRINSIC FOPEN,FREAD,FCONTROL,FWRITE,FCLOSE
> short in_unit = -1;
> short ou_unit = -1;
>
> main() {
> int i;
>
> while (1) {
> i = rd();
> printf("read %d\n", i);
> }
> }
>
> int rd() {
> static unsigned short buffer[1];
> static int chars_read;
> static short len_buffer; /* Length of input buffer */
> static unsigned short fop, aop;
> static char fl[17] = "$STDIN";
> static unsigned short param;
> static short control;
>
> if(in_unit == -1) {
> fop = 132; /* "0000000010000100" */
> aop = 4548; /* "0001000111000100" */
> in_unit = FOPEN(fl, fop, aop);
> if(in_unit == 0) {
> fprintf(stderr,"Error opening $stdin");
> exit();
> }
> /*
> THIS IS THE OFFENDING CODE - IT TURNS CHANNEL INTO BINARY MODE
> */
> control = 27;
> param = 0;
> FCONTROL(in_unit, control, ¶m);
> /*
> END OF OFFENDING CODE - ALL ELSE WORKS
> */
> }
>
> len_buffer = -1;
> buffer[0] = 0;
> chars_read = FREAD(in_unit, buffer, len_buffer);
>
> /* NOTE: FREAD RETURNS 0 IMMEDIATELY IF FCONTROL 27 (BINARY) is SET */
> if (ccode() == 0) { /* A little hack to allow input of : which closes
> port */
> chars_read = 1;
> FCLOSE(in_unit, 0, 0);
> in_unit = -1; /* will get reopened next time around */
> return(':');
> }
> return ((int)(buffer[0] / 256));
> }
>
|