看板 LinuxDev 關於我們 聯絡資訊
Hi, 我用 RS232 接到板子上印出一些東西, 因為 serial port tty 是 line buffered, 所以 我用 setvbuf+_IONBF 設成 no buffer, 所以若是我的程式裡面寫 printf("hello \n"); printf("world"); while(1) { /* Wait for some event and exit */ } "world" 是可以印出來的, 但是若寫成像 char *str = "beautiful"; printf("hello \n"); printf("world is %s", str); while(1) { /* Wait for some event and exit */ } 則 "beautiful" 還是要等到 while 裡面的事情做完才會印 可以給我提示怎麼解決嗎? Thanks. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.209.21
sunneo:直接把printf改為fprintf(stderr吧 03/26 03:38
sunneo:歐..是line buf,那試試看用buf + iomap, 再以prot_read 03/26 03:41
sunneo:用fflush來作為handler 03/26 03:42