Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I send data from a serial port

Status
Not open for further replies.

pag

MIS
Apr 27, 1999
2
0
0
GB
I can recieve data ok but I can't export it out. <br>
This is the source I am using.<br>
#include &lt;stdio.h&gt;<br>
#include &lt;bios.h&gt;<br>
<br>
<br>
unsigned comminset;<br>
unsigned commoutset;<br>
unsigned datain;<br>
unsigned dataout;<br>
<br>
int portin;<br>
int portout;<br>
unsigned int comstatus;<br>
int count;<br>
unsigned char out;<br>
unsigned char in;<br>
<br>
<br>
void main(void)<br>
{<br>
printf("%s\n","Enter Input Port");<br>
scanf("%i",&portin);<br>
printf("%s\n","Enter Output Port");<br>
scanf("%i",&portout);<br>
<br>
/* initialise input serial port settings 9600,E,1,7*/<br>
comminset = _COM_CHR7+_COM_STOP1+_COM_EVENPARITY+_COM_9600;<br>
comstatus = _bios_serialcom(_COM_INIT,portin-1,comminset);<br>
printf("%s %i %s\n","Comm Port",portin,"Initialised For Input");<br>
<br>
/* initialise output serial port settings 9600,E,1,7*/<br>
commoutset = _COM_CHR7+_COM_STOP1+_COM_EVENPARITY+_COM_9600;<br>
comstatus = _bios_serialcom(_COM_INIT,portout-1,commoutset);<br>
printf("%s %i %s\n","Comm Port",portout,"Initialised For Output");<br>
count=0; <br>
for (; ;)<br>
{<br>
/*read character from input port*/<br>
comstatus = _bios_serialcom(_COM_RECEIVE,portin-1,comminset);<br>
in=comstatus;<br>
out=in;<br>
printf("%hu ",comstatus);<br>
if (in&lt;127)<br>
{<br>
if (in=='\45') <br>
{<br>
count++;<br>
if (count &gt;= 180)<br>
{<br>
count=0;<br>
out='\04';/*send EOT character to output port*/<br>
}<br>
else<br>
{<br>
out=in;<br>
}<br>
}<br>
}<br>
printf("%c %c %3d\r",in,out,count);<br>
commoutset=out;<br>
_bios_serialcom(_COM_SEND,portout-1,commoutset);<br>
}<br>
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top