LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-16-2009, 04:53 AM   #1
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
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 !

Last edited by TheIndependentAquarius; 10-19-2009 at 12:43 AM.
 
Old 10-19-2009, 12:16 AM   #2
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Original Poster
Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
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

Last edited by TheIndependentAquarius; 10-19-2009 at 12:45 AM.
 
Old 10-20-2009, 02:18 AM   #3
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Original Poster
Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
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");

Last edited by TheIndependentAquarius; 09-29-2010 at 05:52 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem to write to serial port os2 Programming 7 05-10-2013 04:33 PM
TO write to a serial port payu21 Linux - Newbie 1 05-24-2009 09:23 AM
Should be dead simple - read/write serial port from bash ericcarlson Linux - Software 3 10-21-2006 08:35 PM
How do i write to a serial port (modem) in ascii or hex directly? Taliesin.duchaos Linux - Networking 6 04-21-2006 08:31 AM
Serial port Read Write SeanatIL Programming 2 07-14-2004 03:42 PM


All times are GMT -5. The time now is 04:50 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration