-
communication
hi im trying to do serial communication between two computers using bioscom. I have two graphics programs in a win 32 environment not DOS.
Basically if i press a key say a 4 on the keyboard on one of the computers i need it to go thru the communications line and carry out a function in the program on the other computer. My problem is i dont know how to send a character to the other computer and get it to act as if a key was hit on that computer. and take input and carry out a function.
I know bioscom only deals with characters and as im sending integers i need to translate them using itoa......but how do i do it all?
ive established communication between the computers using
Code:
#include <bios.h>
#define DATA_READY 0x100
#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00)
int main (void){
int COM1 = 0;
int status, OK=0;
printf("\t\t\tSetting up communications");
printf("\n\n\nEnter Communication port being used: ");
scanf("%d", &COM1);
COM1--;
bioscom(0, SETTINGS, COM1);
status=bioscom(3, 0, COM1);
if (status & DATA_READY){
printf("communication OK - any key to continue");
OK=1;
getch();
}
return 0;
}
i've looked all over the net and thru books but i cant find anything that i understand :( plz can someone help me?
-
because i was told that i have to use bioscom :( but i dont know how to....
-
I got this from Borland's library reference book (watered down for length) for _bios_serialcom if it will be of any use.
Code:
#define com1 0
#define DATA_READY 0x100
#define TRUE 1
#define FALSE 0
#define SETTINGS (_COM_1200 | _COM_CHR7 | _COM_STOP1 | COM_NOPARITY)
...// main
unsigned in, out, status;
_bios_serialcom(_COM_INIT, COM1, SETTINGS);
for(;;)
{
status = _bios_serialcom(_COM_STATUS, COM1, 0);
if(status & DATA_READY)
if((out = _bios_serialcom(_COM_RECIEVE, COM1, 0) & 0x7F) != 0)
putch(out);
in = getch();
_bios_serialcom(_COM_SEND, COM1, in);
}
../ end main
I'd expect that in could also be used to send one byte at a time from a string using something like
Code:
char string[] = "test string";
int i;
for(;;) // from Borland's code
{
for(i = 0; string[i] != '\0'; i++)
_bios_serialcom(_COM_SEND, COM1, string[i]);
I haven't tried that myself, but I'd be interested in knowing if any part of it works. Good luck.
-
It is ammazing what you can find on google, and this is one of many hits....
http://www.delorie.com/djgpp/doc/libc/libc_68.html
this one looks what you maybe after
http://www.ontrak.net/c.htm
and the search took the same time to type this reply..hope it helps.