| View previous topic :: View next topic |
| Author |
Message |
J.H.Kim Guest
|
Posted: Mon Nov 10, 2008 8:18 am Post subject: simple serial program |
|
|
Hi, everyone
I wrote a simple serial program to test tty routines.
It just writes a simple text to serial port "/dev/ttyS1".
The open routine succeeded, which finally called serial8250_startup() in
kernel, but write routine did not call the kernel routine "tty_write()"
for /dev/ttyS1.So, it did not call uart_write(), either.
echo test > /dev/ttyS1 is OK.
tty_write() and uart_write() are all normally called.
Please tell what is wrong with my simple test routine.
The routine was like this:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
int main() {
FILE *fp;
fp = fopen("/dev/ttyS1", "rw");
fprintf(fp, "This is test\n");
fclose(fp);
}
Thanks in advance.
Regards,
J.H.Kim |
|
| |
|
Back to top |
Jan Panteltje Guest
|
Posted: Mon Nov 10, 2008 3:22 pm Post subject: Re: simple serial program |
|
|
On a sunny day (Mon, 10 Nov 2008 14:02:59 +0900) it happened "J.H.Kim"
<frog1120@gmail.com> wrote in <gf8f0a$b98$1@localhost.localdomain>:
| Quote: | Hi, everyone
I wrote a simple serial program to test tty routines.
It just writes a simple text to serial port "/dev/ttyS1".
The open routine succeeded, which finally called serial8250_startup() in
kernel, but write routine did not call the kernel routine "tty_write()"
for /dev/ttyS1.So, it did not call uart_write(), either.
echo test > /dev/ttyS1 is OK.
tty_write() and uart_write() are all normally called.
Please tell what is wrong with my simple test routine.
The routine was like this:
#include <unistd.h
#include <stdio.h
#include <stdlib.h
#include <sys/stat.h
#include <fcntl.h
int main() {
FILE *fp;
fp = fopen("/dev/ttyS1", "rw");
fprintf(fp, "This is test\n");
fclose(fp);
}
Thanks in advance.
Regards,
J.H.Kim
|
Just about everything is wrong.
At first you should check the return value from fopen().
Here is a simple serial program that works, and actually initialises the serial device,
simpler then this is not easy:
http://panteltje.com/panteltje/pic/io_pic/ptlrc-0.2.tgz |
|
| |
|
Back to top |
J.H.Kim Guest
|
Posted: Mon Nov 10, 2008 3:44 pm Post subject: Re: simple serial program |
|
|
Jan Panteltje ? ?:
| Quote: | On a sunny day (Mon, 10 Nov 2008 14:02:59 +0900) it happened "J.H.Kim"
frog1120@gmail.com> wrote in <gf8f0a$b98$1@localhost.localdomain>:
Hi, everyone
I wrote a simple serial program to test tty routines.
It just writes a simple text to serial port "/dev/ttyS1".
The open routine succeeded, which finally called serial8250_startup() in
kernel, but write routine did not call the kernel routine "tty_write()"
for /dev/ttyS1.So, it did not call uart_write(), either.
echo test > /dev/ttyS1 is OK.
tty_write() and uart_write() are all normally called.
Please tell what is wrong with my simple test routine.
The routine was like this:
#include <unistd.h
#include <stdio.h
#include <stdlib.h
#include <sys/stat.h
#include <fcntl.h
int main() {
FILE *fp;
fp = fopen("/dev/ttyS1", "rw");
fprintf(fp, "This is test\n");
fclose(fp);
}
Thanks in advance.
Regards,
J.H.Kim
Just about everything is wrong.
At first you should check the return value from fopen().
Here is a simple serial program that works, and actually initialises the serial device,
simpler then this is not easy:
http://panteltje.com/panteltje/pic/io_pic/ptlrc-0.2.tgz
|
The option for fopen() was wrong.
When I put the option "w+" rather than "rw", it works.
Thank you.
Regards,
J.H.Kim |
|
| |
|
Back to top |
|