This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
serial output problem:cyg_io_write and printf
- From: "liu hua" <rongye_liu at hotmail dot com>
- To: ecos-discuss at sources dot redhat dot com
- Date: Wed, 09 Mar 2005 17:06:22 +0800
- Subject: [ECOS] serial output problem:cyg_io_write and printf
- Bcc:
When I use cyg_io_write() write serial(/dev/tty0) in the main() function,it
is ok. But when I use cyg_io_write() in a thread created in main(),the
serial port have no output message.
The simple program is:
int main(void)
{
cyg_io_handle_t handle;
Cyg_ErrNo err;
char read_string[50];
const char test_string[] = "serial example is working correctly!\n";
cyg_uint32 len = strlen(test_string);
printf("Starting serial example\n");
err = cyg_io_lookup( "/dev/tty0", &handle );
if (ENOERR == err) {
printf("Found /dev/tty0. Writing string....\n");
err = cyg_io_write( handle, test_string, &len );
}
if (ENOERR == err) {
printf("I think I wrote the string. Did you see it?\n");
}
}
the output message is:
Starting serial example
Found /dev/tty0. Writing string....
I think I wrote the string. Did you see it?
serial example is working correctly!
But,if I use follow program:
static void simple_prog(CYG_ADDRESS data)
{
cyg_io_handle_t handle;
Cyg_ErrNo err;
char read_string[50];
const char test_string[] = "serial example is working correctly!\n";
cyg_uint32 len = strlen(test_string);
printf("Starting serial example\n");
err = cyg_io_lookup( "/dev/tty0", &handle );
if (ENOERR == err) {
printf("Found /dev/tty0. Writing string....\n");
err = cyg_io_write( handle, test_string, &len );
}
if (ENOERR == err) {
printf("I think I wrote the string. Did you see it?\n");
}
}
int main(void)
{
cyg_thread_create(4, simple_prog, (cyg_addrword_t) 0, "serial",
(void *)stack[0], STACKSIZE, &thread[0],
&thread_obj[0]);
cyg_thread_resume(thread[0]);
}
the output messages is:
Starting serial example
Found /dev/tty0. Writing string....
I think I wrote the string. Did you see it?
There is no cyg_io_write() output message "serial example is working
correctly!" .
In this program,I have two problem:
1) In a thread created in main(),why cyg_io_write() cannt write serial
port?
2) In main(),the cyg_io_write() can write serial port,but the output
message is in the last line (after all printf()).Why?
I need get some HELP !
_________________________________________________________________
免费下载 MSN Explorer: http://explorer.msn.com/lccn
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss