serial port question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all!

I have a question about work with serial port (rs232) in kernel
How todo this?
Here
http://www.kernelnewbies.org/documents/kdoc/kernel-api/linuxkernelapi.html
iam not find any docs about serial rs232 communication.

For example i have in user-space this OpenPort() implementation for my
programm:
------------------------------------------
#include <sys/ioctl.h>
#include <linux/serial.h>
#include <unistd.h>
#include <termios.h>
...
...
        sprintf(devName, "/dev/ttyS%d", ComNum - 1);
        hComm = open(devName, O_RDWR | O_NOCTTY | O_NONBLOCK);
        if(hComm < 0)
                return false;
        BaudRate = B9600;
        fcntl(hComm, F_SETFL, 0);
        termios dcbComm;
        tcgetattr(hComm, &dcbComm);
 
        cfsetospeed(&dcbComm, BaudRate);
        cfsetispeed(&dcbComm, BaudRate);

        dcbComm.c_cflag &= ~(PARENB/*|CSTOPB*/|CRTSCTS|CSIZE);
        dcbComm.c_cflag |= CREAD|CS8;
 
        dcbComm.c_cc[VMIN] = 0;
        dcbComm.c_cc[VTIME] = 10;
 
        dcbComm.c_iflag &= ~(INLCR|IGNCR|ICRNL|IUCLC);
        cfmakeraw(&dcbComm);
/*
termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
termios_p->c_oflag &= ~OPOST;
termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
termios_p->c_cflag &= ~(CSIZE|PARENB);
termios_p->c_cflag |= CS8;
*/
tcflush(hComm, TCIFLUSH);
tcsetattr(hComm, TCSANOW, &dcbComm);
------------------------------------------------
How todo this in kernel mode?
Btw. I write kernel module for device connected through rs232...

DaemonSerj
-----------------------
mailto:DaemonSerj@mail.ru

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux