Serial port Communication
Dear Experts,
i trying to read the data from serial port COM1,
though my program is correct i am not understanding how to provide the inputs and how to check its output,
Code:
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#define PORT1 0x3F8 /* Defines Serial Port Base Address (COM1 */
void main(void){
unsigned char c = 0;
unsigned char chrctr = 0;
/*int exit = 1; */
outportb(PORT1 + 1, 0); /* Turn off interrupts */
/* PORT1 Communication Settings */
outportb(PORT1 + 3, 0x80); /* Set DLAB ON */
outportb(PORT1 + 0, 0x0C); /* Set the baud rate to 9600 */
outportb(PORT1 + 1, 0x00); /* Set Baud - Divisor latch HIGH */
outportb(PORT1 + 3, 0x03); /* 8 bits, no parity, 1 stop */
outportb(PORT1 + 2, 0xC7); /* FIFO Control Register */
outportb(PORT1 + 4, 0x0B); /* Turn on DTR, RTS, and OUT2) */
printf("Waiting on transmission from source.\nPress ESC to quit.\n");
while(chrctr != 27){ /* Execute the loop if ESC has been hit */
c = inportb(PORT1 + 5);
if (c & 0x01){
chrctr = inportb(PORT1);
printf("%d",chrctr);
}
if (kbhit()){
chrctr = getch();
outportb(PORT1, chrctr);
}
}
}"
when i execute this program at dos prompt it says
Code:
Waiting on transmission from source.\nPress ESC to quit.
and when i press escape it will come out as the loop suggest
but i want communicate through that port please tell me how to check the outputs for this program as i am not much aeware of it please experts tell me how read the data from the serial COM1.
serial port communication
Dear experts,
thank you for your reply,
yes i am widows xp and installed the turbo c here and trying to run that program , is it is right way,
please help me i want to communicate to serial port
COM1, what i have to do , or what modifications has to be done, in device manager which properties need to be checked,
whether it is General, Driver,Port Settings,Details or Resources.
please help me,
with regards,
vidya.
Serial port communication
Dear experts,
thank you for u r reply,
ya that COM1
i/o range it shows:03F8-03FF
what i am doing is i am working on windows Xp and installed the turbo c here,
and went through run->cmd (command line)
c:\tc>tc
i got the editor where i typed this program and compiled it compiled fine,
and when executed it simply shows nothing ,
so how to communicate properly please advice me,
how to modify this so that we can communicate please advice me.
Serial port Communication
dear Experts,
please provide me a code which does serial communication through COM ports,
really i am strucked badly ,
including please tell me how check its inputs,
please help me.
serial port communication
what is the output of this program,
Code:
#include <stdio.h>
unsigned char pBuffer[1024];
FILE* pFile = fopen("com1:" , "r+b");
fread(pBuffer , 1024 , 1 , pFile);
fclose(pFile);
it openes the file successfully but after nothing displays what is the output what should be checked please tell me........
serial port communication
dear experts,
thanks you for u r reply,
thats what i wanted at last , through COM1 iwant to connect the printer and perform some activities, like printing one of my document, how to do that how to connect the printer to that COM1 serial port,
please please tell me.
serial port communication
Thank you for u r reply,
i will definitely check the hyper terminal with COM1 port,
but my actual question is how to connect the printer to the COM1 port,
still i have not connected it,what is the procedure,
as i have set of procedure how to connect hyper terminal , how to configure it through COM1 is there any way to connect the printer,
please tell me.
serial port communication
dear experts,
thank u for reply,
ya i understood know,as u suggested i used the Hyperterminal to check whether COM ports are working, for that i used one serial cable ,
but it worked for following configuration of COM1
Bits per second :9600
Data bits :8
Parity :none
Stopbits :2
Flow control :xon/xoff
so my question is whether i can use this configuration and use that serial cable
and and use my program to communicate between 2pcs, and also what is the configuration that i have to replace for Flow control:xon/xoff which was 0 previously.
what are u r suggestions insead of printer is it possible to make communication between two pcs, please give me u r suggestion, how to do, whether one
hyperterminal and one program or running program on both the PCs,
please help me.
serial port communication
dear experts,
really sorry for my post if it is really felt very bad to you,
as i intially said i dont know anything about serial port communication and i am following the steps what u were referring me,
anyhow my actual task was to do a serial communication with printer, but after checking everything i found that serial printer was not available so i thought of atleast communicating in between two PCS, for that your hyperterminal concept had helped me,
once again if you felt this thread is useless or wasting your time i am extremely sorry, thanks for all your replies.