Final code for our 4180 Drawing Robot!

Dependencies:   4DGL-uLCD-SE gCodeParser mbed

Committer:
jford38
Date:
Wed Apr 30 16:40:10 2014 +0000
Revision:
2:ba15545a4ccf
Added Visual Studio Source files and README.; Alejandro.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jford38 2:ba15545a4ccf 1 #include "stdafx.h"
jford38 2:ba15545a4ccf 2 #include "listCOM.h"
jford38 2:ba15545a4ccf 3 #include "string.h"
jford38 2:ba15545a4ccf 4
jford38 2:ba15545a4ccf 5 #using <System.dll>
jford38 2:ba15545a4ccf 6
jford38 2:ba15545a4ccf 7 using namespace System;
jford38 2:ba15545a4ccf 8 using namespace System::IO::Ports;
jford38 2:ba15545a4ccf 9 using namespace System::ComponentModel;
jford38 2:ba15545a4ccf 10
jford38 2:ba15545a4ccf 11 _TCHAR my_port[NAME_SIZE];
jford38 2:ba15545a4ccf 12
jford38 2:ba15545a4ccf 13 _TCHAR* listCOM()
jford38 2:ba15545a4ccf 14 {
jford38 2:ba15545a4ccf 15 wcscpy(my_port, L"\\\\.\\");
jford38 2:ba15545a4ccf 16 _TCHAR temp[10];
jford38 2:ba15545a4ccf 17
jford38 2:ba15545a4ccf 18 array<String^>^ serialPorts = nullptr;
jford38 2:ba15545a4ccf 19 try
jford38 2:ba15545a4ccf 20 {
jford38 2:ba15545a4ccf 21 // Get a list of serial port names.
jford38 2:ba15545a4ccf 22 serialPorts = SerialPort::GetPortNames();
jford38 2:ba15545a4ccf 23 }
jford38 2:ba15545a4ccf 24 catch (Win32Exception^ ex)
jford38 2:ba15545a4ccf 25 {
jford38 2:ba15545a4ccf 26 Console::WriteLine(ex->Message);
jford38 2:ba15545a4ccf 27 }
jford38 2:ba15545a4ccf 28
jford38 2:ba15545a4ccf 29 Console::WriteLine("The following serial ports were found:");
jford38 2:ba15545a4ccf 30
jford38 2:ba15545a4ccf 31 // Display each port name to the console.
jford38 2:ba15545a4ccf 32 for each(String^ port in serialPorts)
jford38 2:ba15545a4ccf 33 {
jford38 2:ba15545a4ccf 34 Console::WriteLine(port);
jford38 2:ba15545a4ccf 35 _snwprintf(temp, NAME_SIZE, L"%hs", port);
jford38 2:ba15545a4ccf 36 wcscat_s(my_port, NAME_SIZE, temp);
jford38 2:ba15545a4ccf 37
jford38 2:ba15545a4ccf 38 }
jford38 2:ba15545a4ccf 39 return my_port;
jford38 2:ba15545a4ccf 40 }