# On Thu, 19 Aug 2004 21:33:23 -0000
#
# > # So go and ask on a a group for you platform as Mark suggested.
# > Standard# C does not provide you with any way to to what you want and
# > this group# talks about standard C.
# >
# > Still shooting from the hip and blowing off your own toes. Depending
# ^^^^^^^^^
# > on the operating system, it may be possible to fopen a device name and
# ^^^^^^^^^^^^^^^^^^^^^^^
# > then use stdio to read/write the port.
#
# You said it yourself, it DEPENDS ON THE OPERATING SYSTEM. Therefor it
If you actually botherred to think about it for a moment, openning any
file DEPENDS ON THE OPERATING SYSTEM. Disk file, terminal, any file at
all. So is openning a disk file something you cannot do in standard C,
just because it requires a system to map file names into disk files?
# needs to be asked in a group dealing with the operating system. If the
# OP find it can be done using fopen and friends, then questions can be
# asked about the things which can be done in standard C. However, if the
# OP knew that was possible then the question would not have been asked.
That's a silly claim. I don't know if the OP knows whether his system
maps devices to file names or not. That part is system specific. But if
it is possible, then the device can be openned and read and written in
standard C. Explain exactly what part of the following code is not ANSI C.
#include <stdio.h>
static FILE *openport(int port,int speed,int csize,char parity) {
char path[100],conf[100];
sprintf(path,"/dev/ttyS%d",port);
sprintf(conf,"stty -f /dev/stty -f /dev/ttyS%d speed %d cs%d %s",
port,speed,csize,
parity=='n' ? "-parenb"
: parity=='o' ? "parenb parodd"
: "parenb -parodd");
if (!system(0)) return 0;
if (system(conf)) return 0;
return fopen(path,"r+");
}
And then tell me again how it is impossible to talk to a device in
ANSI C.