Re: [問題] 在kernel裡,如何直接使用rs232傳送資料

看板LinuxDev作者 (Neo1978)時間18年前 (2007/06/16 10:38), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《aher2600 (和)》之銘言: : 在一般應用程式中,只要 : main() : { : int fd; : fd=open("/dev/ttyS0",....); : . : . : . : read(fd,....); : . : . : . : write(fd,...); : . : . : close(fd); : } : 大致上就可以透過rs232傳送或接收資料了 : 可是小弟現在想在kernel的程式中直接使用"\dev\ttyS0"傳送 : 不知道程式該怎麼寫 : 煩請版友指點 在 init/do_mount.c 中可以看到這樣的 code: fd = open("/dev/console", O_RDWR, 0); if (fd >= 0) { sys_ioctl(fd, TCGETS, (long)&termios); termios.c_lflag &= ~ICANON; sys_ioctl(fd, TCSETSF, (long)&termios); read(fd, &c, 1); termios.c_lflag |= ICANON; sys_ioctl(fd, TCSETSF, (long)&termios); close(fd); } 在 kernel 中你還是可以用 open/close/read/write/ioctl ... 只是要知道這裡的 function 和你平常在 libc 中常用的並不一樣... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.133.70.86
文章代碼(AID): #16SqqmgF (LinuxDev)
文章代碼(AID): #16SqqmgF (LinuxDev)