Run Bluetooth between the artemis board and the computer
To start with I downloaded the source code found on the course website
here, which had all the relevant python and c code.
I also plugged in the usb to bluetooth adapter we were given in our kits, and reran the commands to install bleak.
Next, I uploaded the code to the Artemis board from the Arduino IDE, confirming that the blue LED blinked and the serial monitor printed the requisite information
Next, I ensured I could use USB devices in the VM by enabling them in VirtualBox manager
After first running main.py in the VM, I got bleak errors. Then, I got bluetooth adapter not found issues. After some headscratching and good-ole ECE turning it off and turning it back on again, I found that I had to reconnect the bluetooth module after the VM was already running, else it would not be found. It finally found my device! I added the robot's address to settings.py as well to speed up the process in the future.
await theRobot.ping()
case START_BYTESTREAM_TX
, which showed that there was a tricky type-conversion format that I was unfamiliar with. Copying that, I added ((float *)(res_cmd->data))[0] = 3.14159f;
, and changed TODO_VAL to 1. When I tried that, I got the error that it needed 4 bytes, so I changed the number to 4, but that still didn't work.
case REQ_FLOAT:
Serial.println("Going to send a float");
res_cmd->command_type = GIVE_FLOAT;
res_cmd->length = 8;
((float *)(res_cmd->data))[0] = 3.14159f;
amdtpsSendData((uint8_t *)res_cmd, 6);
break;
bytestream_active = true;
in case START_BYTESTREAM_TX:
and adding a 32 bit value to the amdtpsSendData function, setting the length to 6, and setting command_type to BYTESTREAM_TX. I was getting errors about the having bad chars.
bytestream_active = false;
after it had sent once, and actually looking at the raw output again.
await theRobot.sendCommand(Commands.REQ_FLOAT)
instead of using await theRobot.testByteStream(25)
, because I wasn't entirely sure what was going on there, and using the memcpy() function suggested on campuswire. Finally, I was not getting any errors.
if (bytestream_active)
{
res_cmd->command_type = BYTESTREAM_TX;
res_cmd->length = 64;
//TODO: Put an example of a 32-bit integer and a 64-bit integer
//for the stream. Be sure to add a corresponding case in the
//python program.
uint32_t numToSendShort = 15960;
uint64_t numToSendLong = 100000007;
memcpy(res_cmd->data, &numToSendShort, 4);
memcpy(res_cmd->data+4, &numToSendLong, 8);
//Serial.printf("Stream %d \n", bytestream_active);
amdtpsSendData((uint8_t *)res_cmd, 14);
unsigned long timePassed = micros();
Serial.printf("Cycle %d took %d us\n", numByteStreams, timePassed);
numByteStreams += 1;
}