Start: 10:00
Com Console:
- Added StringEnum class because it is useful for keeping track of valid commands, responses, states, and serials. Made it inherits from Printable so it will be able to print to console.
- Fixed the compiling errors in Command, Response, and State
- The methods for serial tracking as well as some other methods make these classes superior to the structs.
ComMgr:
- Realized I was still using the hard coded com port. Making it so it can use a number that was passed in was a bit tricky. CreateFile uses wchar_t which are not easy to manipulate with sprintf. CreateFileA use LPCSTR which works with standard character arrays. sprintf_s allows you to manipulate a standard character array as opposed to a char pointer array
- Added a resetPort method. I think its better that you do it manually after making all the setting changes. Also added changePort method.
char portNum[32];
sprintf_s(portNum, sizeof(portNum),”COM%d:”, _port);
hCom = CreateFileA(portNum, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
- Added run function so the send and receive methods didn’t need to be called individually.
- Still trying to find a tutorial for transmitting large objects. Want to get this working before I start working on the ArduinoController and tweaking the command, response, and state classes.
Notes On Using pointers:
- Phil showed me how to use pointers to copy a string byte by byte to a memory location allocated to integers.
- Create a pointer of type x(in this case a char*)
- Create another pointer and set it equal to this pointer. This sets it to the beginning of the memory allocation.
- Create another allocation of memory to be copied to(In this case it was an array of 256 integers)
- Create another pointer and set it to the memory address of the new allocation. Cast this to the type of the original data(in this case char)
- Start a loop which runs til it reaches the size of the original allocation
- Within the loop, set the contents of the new allocation equal to the contents of the old then increment both pointers.
- After the loop, set reset the new allocations pointer back to the beginning of the memory address.
Going to try doing this with different data types, arrays, and structs tomorrow.
End: 6:30
