LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to write to a serial port ? (https://www.linuxquestions.org/questions/linux-general-1/how-to-write-to-a-serial-port-762331/)

Aquarius_Girl 10-16-2009 04:53 AM

How to write to a serial port ?
 
i have written an interrupt handler w.r.t to the serial ports. Kindly guide me how to detect an active serial port on suse 10.3.

I have a loopback hardware, I have plugged it into the serial port.

I've written a isr w.r.t to the serial port but, I wanted to know how to write to a serial port, in order to test my program !

Aquarius_Girl 10-19-2009 12:16 AM

I have found out the command to check my system's serial support:
You can run the following command from root login !

dmesg | grep tty

This command gives the list of active serial ports on your comp. as follows:

serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:08: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

Aquarius_Girl 10-20-2009 02:18 AM

I got a new problem with the following interrupt handler code with respect to serial port 1. I have a cable connecting two serial ports of two computers with linux on them. On one computer there is minicom installed and on another I have compiled and successfully insmoded the below shown module. But when I type on minicom, it doesnt show anything (by the command 'dmesg') on the other computer where my module is loaded !

Kindly help !!
Quote:

#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include <linux/fs.h>
#define PORT 0x3F8

irq_handler_t isrSerialPort (int irq, void *dev_id, struct pt_regs *regs)
{
printk ("\n Thank god \n");
return (irq_handler_t) IRQ_HANDLED;
}

int init_module ()
{
/* port+3: Lcr
0x80: 8th bit [DLAB] set to 1
sets speed of communication, bits per second
*/
outb (0x80, PORT + 3);

/*
set the speed to 38,400 Bits per second.
*/
/* Set Baud rate - Divisor Latch Low Byte */
outb (0x03, PORT + 0);

/* Set Baud rate - Divisor Latch High Byte */
outb (0x00, PORT + 1);

/* number of bytes to read */
outb (0xC7, PORT + 2);

/* Interrupt when data received */
outb (0x01, PORT + 1);

request_irq (4, (irq_handler_t) isrSerialPort, SA_SHIRQ, "God", (void *)(isrSerialPort));
}

MODULE_LICENSE ("GPL");


All times are GMT -5. The time now is 10:12 PM.