RS232 Programming for Visual C++ 2010
I am working on a project and I'm trying to fiure out how I'm going to write to the serial port. Since my laptop does not have a serial port, I have purchased a usb to serial adapter. Now I need to send data from my C program to the serial port but I do not know how to address the port.
I tried using this: http://cboard.cprogramming.com/netwo...x-windows.html
However, I am getting compiler errors: "'PortDCB' : undeclared identifier " among others.
(I am using Windows 7 64 bit and I am programming in Visual C++ 2010)Any ideas why or how I can solve this?
(Full list of errors below)
Thanks
Errors:
1>------ Build started: Project: CarSimulation, Configuration: Debug Win32 ------
1> serial.c
1> rs232.c
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(250): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(252): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(254): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(256): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(258): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(260): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(262): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(264): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(266): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(268): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(270): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(272): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(274): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(298): error C2275: 'DCB' : illegal use of this type as an expression
1> c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(747) : see declaration of 'DCB'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(298): error C2146: syntax error : missing ';' before identifier 'port_settings'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(298): error C2065: 'port_settings' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(299): error C2065: 'port_settings' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(299): error C2065: 'port_settings' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(300): error C2065: 'port_settings' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(300): error C2224: left of '.DCBlength' must have struct/union type
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(300): error C2065: 'port_settings' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(302): error C2065: 'port_settings' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(302): warning C4133: 'function' : incompatible types - from 'int *' to 'LPDCB'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(309): error C2065: 'port_settings' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(309): warning C4133: 'function' : incompatible types - from 'int *' to 'LPDCB'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(318): error C2275: 'COMMTIMEOUTS' : illegal use of this type as an expression
1> c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(755) : see declaration of 'COMMTIMEOUTS'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(318): error C2146: syntax error : missing ';' before identifier 'Cptimeouts'
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(318): error C2065: 'Cptimeouts' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(320): error C2065: 'Cptimeouts' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(320): error C2224: left of '.ReadIntervalTimeout' must have struct/union type
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(321): error C2065: 'Cptimeouts' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(321): error C2224: left of '.ReadTotalTimeoutMultiplier' must have struct/union type
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(322): error C2065: 'Cptimeouts' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(322): error C2224: left of '.ReadTotalTimeoutConstant' must have struct/union type
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(323): error C2065: 'Cptimeouts' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(323): error C2224: left of '.WriteTotalTimeoutMultiplier' must have struct/union type
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(324): error C2065: 'Cptimeouts' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(324): error C2224: left of '.WriteTotalTimeoutConstant' must have struct/union type
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(326): error C2065: 'Cptimeouts' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.c(326): warning C4133: 'function' : incompatible types - from 'int *' to 'LPCOMMTIMEOUTS'
1> car.c
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.h(69): warning C4028: formal parameter 1 different from declaration
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.h(69): warning C4028: formal parameter 2 different from declaration
1>c:\users\user\documents\visual studio 2010\projects\gapt\tests\carsimulation\carsimulati on\rs232.h(69): error C2371: 'cprintf' : redefinition; different basic types
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\conio.h(121) : see declaration of 'cprintf'
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========