Final code for our 4180 Drawing Robot!
Dependencies: 4DGL-uLCD-SE gCodeParser mbed
Diff: VStudio2013_Sources/listCOM.cpp
- Revision:
- 2:ba15545a4ccf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VStudio2013_Sources/listCOM.cpp Wed Apr 30 16:40:10 2014 +0000 @@ -0,0 +1,40 @@ +#include "stdafx.h" +#include "listCOM.h" +#include "string.h" + +#using <System.dll> + +using namespace System; +using namespace System::IO::Ports; +using namespace System::ComponentModel; + +_TCHAR my_port[NAME_SIZE]; + +_TCHAR* listCOM() +{ + wcscpy(my_port, L"\\\\.\\"); + _TCHAR temp[10]; + + array<String^>^ serialPorts = nullptr; + try + { + // Get a list of serial port names. + serialPorts = SerialPort::GetPortNames(); + } + catch (Win32Exception^ ex) + { + Console::WriteLine(ex->Message); + } + + Console::WriteLine("The following serial ports were found:"); + + // Display each port name to the console. + for each(String^ port in serialPorts) + { + Console::WriteLine(port); + _snwprintf(temp, NAME_SIZE, L"%hs", port); + wcscat_s(my_port, NAME_SIZE, temp); + + } + return my_port; +} \ No newline at end of file