Imported Upstream version 2.9.0
[debian/cc1111] / device / examples / serialcomm / windows / test_serialcomm.cpp
1 // Test program for serial communication. Visual C / MFC Version
2 // Bela Torok / bela.torok@kssg.ch, March 2001
3
4 #include <afxwin.h>    // Defines the entry point for the console application.
5
6 #include <string.h>
7 #include <stdio.h>
8
9 #include "serial.h"
10
11 int main(int argc, char* argv[])
12 {
13         HANDLE  hComPort;
14         char buf[128];
15
16         hComPort = SerialInit("com1", 1200, 8, 1, 'N', 'N', 5000, 5000, 2, 128);
17
18         if( hComPort == 0) {
19                 printf("\n\nError initializing %s!\n", "com1");
20                 exit(1);
21         }
22
23         // write string to RS232
24         SerialPuts(&hComPort, "\nInitialize\n");
25 //      sleep(5000);
26         
27         // read string from RS232
28         printf("\nString received: %s\n", SerialGets(buf, sizeof (buf) - 1, hComPort));
29
30         CloseHandle(hComPort);
31
32         return 0;
33 }
34