Final code for our 4180 Drawing Robot!
Dependencies: 4DGL-uLCD-SE gCodeParser mbed
listCOM.cpp
00001 #include "stdafx.h" 00002 #include "listCOM.h" 00003 #include "string.h" 00004 00005 #using <System.dll> 00006 00007 using namespace System; 00008 using namespace System::IO::Ports; 00009 using namespace System::ComponentModel; 00010 00011 _TCHAR my_port[NAME_SIZE]; 00012 00013 _TCHAR* listCOM() 00014 { 00015 wcscpy(my_port, L"\\\\.\\"); 00016 _TCHAR temp[10]; 00017 00018 array<String^>^ serialPorts = nullptr; 00019 try 00020 { 00021 // Get a list of serial port names. 00022 serialPorts = SerialPort::GetPortNames(); 00023 } 00024 catch (Win32Exception^ ex) 00025 { 00026 Console::WriteLine(ex->Message); 00027 } 00028 00029 Console::WriteLine("The following serial ports were found:"); 00030 00031 // Display each port name to the console. 00032 for each(String^ port in serialPorts) 00033 { 00034 Console::WriteLine(port); 00035 _snwprintf(temp, NAME_SIZE, L"%hs", port); 00036 wcscat_s(my_port, NAME_SIZE, temp); 00037 00038 } 00039 return my_port; 00040 }
Generated on Thu Jul 21 2022 12:50:48 by 1.7.2