www.smartbusinesschoices.com

Leading Business and Technology,
News and information


Part of the Identityscape.com network...

getxfactor.com jmoodmusic.com smartbusinesschoices.com mintdepot.com lowfaresalways.com evangelicalview.com shoppingpodder.com soproudlywehail.com webnews.ws currenthumor.com

 

 

simple serial program
   Smart Linux Business Choices! - the Best of UseNet Postings! Forum Index -> Linux Development - Applications  
View previous topic :: View next topic  
Author Message
J.H.Kim
Guest






PostPosted: Mon Nov 10, 2008 8:18 am    Post subject: simple serial program Reply with 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
Back to top
Jan Panteltje
Guest






PostPosted: Mon Nov 10, 2008 3:22 pm    Post subject: Re: simple serial program Reply with 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>:

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






PostPosted: Mon Nov 10, 2008 3:44 pm    Post subject: Re: simple serial program Reply with quote

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
Display posts from previous:   
   Smart Linux Business Choices! - the Best of UseNet Postings! Forum Index -> Linux Development - Applications  
Page 1 of 1
All times are GMT

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum