Dear All,
I have been stucked at a Point with confusion. the file /include/linux/tty.h
Has a structure name tty_struct .
I am not sure but i came across reading that . if i have to transmit a character on the ttyS0 . then i have to use the Functions provided in the file tty_driver.h.
Following functions :
int (*open)(struct tty_struct * tty, struct file * filp);
void (*close)(struct tty_struct * tty, struct file * filp);
int (*write)(struct tty_struct * tty,const unsigned char *buf, int count);
void (*put_char)(struct tty_struct *tty, unsigned char ch); and many more.
m i going correct ?
If yes ....
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
int main()
{
int fd=open("/dev/ttyS0",_IOC_READ);
int i = 0;
printf("=============TEST BEGIN=============\n");
if(fd == -1)
{
printf("Open File Error\n");
exit(0);
}
else
{
printf("Open File SuccessFull=%d\n",fd); === > fd value when i print is 3 ????
}
while(1)
{
//void (*put_char)(struct tty_struct *tty, unsigned char ch);
put_char(?,0x55); ===> i am stucked with this argument ..what i should pass as the first argument.
i dont know where the structure is getting updated. should i pass "tty". ?
Also it says put_char undefined ? which file i should add ?
}
printf("==============TEST END==============\n");
close(fd);
}
Please provide your views on this . i have a bit idea about the Linux.