I managed to come up with some code for making a Serial Port Device communicate with a computer wherein I send it some data and it sends the same data back to me (as a test program). However, the device sends back some different data.
THe code is as follows :
#define MAX 5000 #define COM1 (unsigned short)0x3F8 #define COM2 (unsigned short)0x2F8
int Delay(int num);
printf("Error in TestSerial()!\n");
printf("Success with TestSerial!\n");
int index, value, result=0;
printf("Begin to execute outp() & inp() ... \n");
printf("Data sent to COM1 is : %d \n",index);
printf("Data returned from COM1 is : %d \n",value);
printf("Error in loop testing of COM1! \n");
int Delay(int num)
The problem I am facing is that the device returns different data EVERY time (which is not the sent data of 1-9). Could you please help me out ?
Also, I thought of a way where in _outp() I send a comman that is specific to the device - say it is an instruction in C only .. but then that kind of limits the scope of my program's usage.
P.S. I have used #include <> only but the HTML preview prevents the appropriate usage.
[EDIT: Added tags to code block and restored include statements]