opening a comport in linux
pls help
i am not able to open the comport in linux the code is giving error that port cannot be opend [code[ #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <termios.h> #include <string.h> #include <errno.h> int main() { int fd; /* File descriptor for the port */ fd = open ("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY); if (fd < 0) { /* Could not open the port */ fprintf (stderr, "open_port: Unable to open /dev/ttyS1 - %s\n", strerror (errno)); printf("error in opening com port\n"); return 0; } else return (fd); } } [/code] |
please edit your post and fix the [code[ line (at the beginning)
Can you tell us the error message you got? do you really want to open /dev/ttyS1111? |
Quote:
|
For one thing ... you almost always want to use a communication-protocol library that will get you as close as possible to the finishing-point of the job that you are trying to do. IMHO, if you are thinking "way down at the device level," you're probably creating far too much work for yourself in most cases. That's why there is such a booming business in the manufacture of prefabricated building-parts, like doors and windows.
|
Make sure the user that's running this code has permission to access the device. You could attempt to open it with minicom to confirm.
|
All times are GMT -5. The time now is 12:05 AM. |