Interfacing rs232 with visual c++

hello

I also need a sample code to send commands through rs232 port and receive back. these commands are being send via a bluetooth dongle into a bluetooth module connected to a PIC.

that would be a great help if anybody sends me a code for interfacing serial port.

my email: [email protected]
 
<pre>
#include <bios.h>

#include <conio.h>



#define COM1 0

#define DATA_READY 0x100



#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00)



int main(void)

{

int in, out, status;



bioscom(0, SETTINGS, COM1); /*initialize the port*/

cprintf("Data sent to you: ");

while (1)

{

status = bioscom(3, 0, COM1); /*wait until get a data*/

if (status & DATA_READY)

if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) /*input a data*/

putch(out);

if (kbhit())

{

if ((in = getch()) == 27) /* ASCII of Esc*/

break;

bioscom(1, in, COM1); /*output a data*/

}

}

return 0;

}
</pre>
 
#include <stdio.h>
#include <dos.h>

void main(void)
{
unsigned int far *ptraddr; /* Pointer to location of Port Addresses */
unsigned int address; /* Address of Port */
int a;

ptraddr=(unsigned int far *)0x00000400;

for (a = 0; a < 4; a++)
{
address = *ptraddr;
if (address == 0)
printf("No port found for COM%d \n",a+1);
else
printf("Address assigned to COM%d is %Xh\n",a+1,address);
*ptraddr++;
}
}
 
Top