当前位置: 技术问答>linux和unix
如何在linux内核模块中对串口进行读写
来源: 互联网 发布时间:2015-03-23
本文导语: 在内核中不能读写串口设备文件,哪位有什么解决方案,最好有例子原代码,多谢 送高分 | //我也在找相关资料,有什么好东东,大家拿出来共享,祝你好运。 #include ...
在内核中不能读写串口设备文件,哪位有什么解决方案,最好有例子原代码,多谢
送高分
送高分
|
//我也在找相关资料,有什么好东东,大家拿出来共享,祝你好运。
#include
#include
#include
#include
#include
/* baudrate settings are defined in , which is
included by */
#define BAUDRATE B38400
/* change this definition for the correct port */
#define MODEMDEVICE "/dev/ttyS1"
#define _POSIX_SOURCE 1 /* POSIX compliant source */
#define FALSE 0
#define TRUE 1
volatile int STOP=FALSE;
main()
{
int fd,c, res;
struct termios oldtio,newtio;
char buf[255];
/*
Open modem device for reading and writing and not as controlling tty
because we don't want to get killed if linenoise sends CTRL-C.
*/
fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
if (fd
#include
#include
#include
#include
#include
/* baudrate settings are defined in , which is
included by */
#define BAUDRATE B38400
/* change this definition for the correct port */
#define MODEMDEVICE "/dev/ttyS1"
#define _POSIX_SOURCE 1 /* POSIX compliant source */
#define FALSE 0
#define TRUE 1
volatile int STOP=FALSE;
main()
{
int fd,c, res;
struct termios oldtio,newtio;
char buf[255];
/*
Open modem device for reading and writing and not as controlling tty
because we don't want to get killed if linenoise sends CTRL-C.
*/
fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
if (fd