Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-09-2011, 07:05 AM   #1
Registered: Jan 2011
Posts: 53

Rep: Reputation: 0
Angry Serial loopback test (uart)

Hello Folk,

iam trying to write a loopback test for serial port(COM1)

for this i have done below coding, this code is working fine in my pc(redhat), same is not working in windriver kernel 4.1. Could anybody please correct where iam doing wrong.

also please suggest me a best way of writing serial loopback test.

the UART driver is properly loaded and iam able to telnet the pc(with kernel wind river4.1).

since iam directly reading/writing UART the registers iam thinking that no need to consider baudrate. iam not at all changing any system baudrate(using system default baudrate).

below is the code.

#define BASE_ADDR 0x3f8
int WriteAdrPort(void)
int iOut=1;
char Byte=0;
char i=0;
printf("byte read= %c\n",Byte);
if(Byte == 65+i)
printf("TX and Rx Data not matching\n");
return iOut;

return iOut;

int main(int argc, char *argv[])
unsigned char byte=0;
unsigned char old=0;

byte=(unsigned char)(inb(BASE_ADDR+4)); // address of MCR

printf("setting loopback bit\n");//bit 4 of MCR reg
byte=(byte|16);// setting the loop back bit

outb(byte,(BASE_ADDR+4));//setting the loopback bit

WriteAdrPort() ;
outb(old,(BASE_ADDR+4));// resetting the MCR to default value
return 0;
}//main ends

thanks for your help in advance..

Last edited by shankar.489; 11-10-2011 at 12:14 AM.
Old 11-09-2011, 10:22 AM   #2
Registered: Oct 2007
Location: triad, nc, usa
Distribution: Ubuntu
Posts: 232

Rep: Reputation: 29
I cant help you with coding, but please put the code in [ code ] tags so it keeps formatting, and doesnt take up a mile worth of space


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] problem with ethernet loopback test using loopback plug/stub: receiving socket not se mcha Linux - Kernel 3 08-26-2010 12:28 PM
Serial port UART FIFO buffer override Mar_kas Linux - Hardware 2 05-13-2010 01:47 AM
Serial Driver Failing to Register all Ports of my Quad Uart bramsey123 Linux - Newbie 0 09-13-2007 11:16 AM
Uart serial port + SysRq flook Linux - Hardware 0 11-30-2004 09:57 AM
jpilot/serial UART? amam Linux - General 1 11-01-2001 01:16 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:41 AM.

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