</PropertyGroup>\r
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
- <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+ <ConfigurationType>StaticLibrary</ConfigurationType>\r
<UseDebugLibraries>true</UseDebugLibraries>\r
<CharacterSet>Unicode</CharacterSet>\r
</PropertyGroup>\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
- <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+ <ConfigurationType>StaticLibrary</ConfigurationType>\r
<UseDebugLibraries>false</UseDebugLibraries>\r
<WholeProgramOptimization>true</WholeProgramOptimization>\r
<CharacterSet>Unicode</CharacterSet>\r
#include "Serial.hpp"\r
\r
-Serial::Serial(const char *)\r
+Serial::Serial(const char *, int baudrate)\r
:_connected(false)\r
{\r
}\r
{\r
public:\r
//Initialize Serial communication with the given COM port\r
- __declspec(dllexport) Serial(const char *portName);\r
+ //baudrate among 300 1200 2400 4800 9600 14400 19200 38400 57600 115200\r
+ __declspec(dllexport) Serial(const char *portName, int baudrate = 57600);\r
\r
//Close the connection\r
//NOTA: for some reason you can't connect again before exiting\r
#include <windows.h>
#endif
\r
-SerialWindows::SerialWindows(const char *portName)\r
+SerialWindows::SerialWindows(const char *portName, int baudrate)\r
:Serial(portName)\r
{\r
//Try to connect to the given port throuh CreateFile\r
else\r
{\r
//Define serial connection parameters for the arduino board\r
- dcbSerialParams.BaudRate=CBR_57600;\r
+ switch(baudrate)\r
+ { \r
+ case 300:\r
+ dcbSerialParams.BaudRate=CBR_300; \r
+ break;\r
+ case 1200:\r
+ dcbSerialParams.BaudRate=CBR_1200; \r
+ break;\r
+ case 2400:\r
+ dcbSerialParams.BaudRate=CBR_2400; \r
+ break;\r
+ case 4800:\r
+ dcbSerialParams.BaudRate=CBR_4800; \r
+ break;\r
+ case 9600:\r
+ dcbSerialParams.BaudRate=CBR_9600; \r
+ break;\r
+ case 14400:\r
+ dcbSerialParams.BaudRate=CBR_14400; \r
+ break;\r
+ case 19200:\r
+ dcbSerialParams.BaudRate=CBR_19200; \r
+ break;\r
+ case 38400:\r
+ dcbSerialParams.BaudRate=CBR_38400; \r
+ break;\r
+ case 57600:\r
+ dcbSerialParams.BaudRate=CBR_57600; \r
+ break;\r
+ case 115200:\r
+ dcbSerialParams.BaudRate=CBR_115200; \r
+ break;\r
+ default:\r
+ dcbSerialParams.BaudRate=CBR_57600; \r
+ break;\r
+ }\r
dcbSerialParams.ByteSize=8;\r
dcbSerialParams.StopBits=ONESTOPBIT;\r
dcbSerialParams.Parity=NOPARITY;\r
{\r
public:\r
//Initialize Serial communication with the given COM port\r
- __declspec(dllexport) SerialWindows(const char *portName);\r
+ __declspec(dllexport) SerialWindows(const char *portName, int baudrate = 57600);\r
//Close the connection\r
//NOTA: for some reason you can't connect again before exiting\r
//the program and running it again\r