|
18 | 18 | #include "string.h" |
19 | 19 | #include "hdlc.h" |
20 | 20 |
|
| 21 | +const char HARDWARE[] = "DVM-V24 FW " __TIME__ " " __DATE__; |
| 22 | + |
21 | 23 | uint8_t vcpRxMsg[VCP_RX_BUF_LEN]; |
22 | 24 |
|
23 | 25 | extern bool USB_VCP_DTR; |
@@ -122,6 +124,10 @@ void VCPCallback() |
122 | 124 | // Send the UI |
123 | 125 | HDLCSendUI(p25data, length - 4); |
124 | 126 | } |
| 127 | + else if (command == CMD_GET_VERSION) |
| 128 | + { |
| 129 | + sendVersion(); |
| 130 | + } |
125 | 131 | LED_USB(0); |
126 | 132 | } |
127 | 133 |
|
@@ -209,13 +215,43 @@ bool VCPWriteP25Frame(const uint8_t *data, uint16_t len) |
209 | 215 | #endif |
210 | 216 | #ifdef TRACE_VCP |
211 | 217 | uint8_t hexStrBuf[(len+3)*4]; |
212 | | - printHexArray((char*)hexStrBuf, buffer, len+3); |
| 218 | + printHexArray((char*)hexStrBuf, buffer, len+3, " "); |
213 | 219 | log_trace("Sending %s", hexStrBuf); |
214 | 220 | #endif |
215 | 221 |
|
216 | 222 | return VCPWrite(buffer, len+4); |
217 | 223 | } |
218 | 224 |
|
| 225 | +/** |
| 226 | + * @brief Send the V24 board version and UID over the VCP |
| 227 | + * |
| 228 | + * Stolen from the DVM modem firmware |
| 229 | +*/ |
| 230 | +void sendVersion() |
| 231 | +{ |
| 232 | + uint8_t reply[200U]; |
| 233 | + |
| 234 | + reply[0U] = DVM_FRAME_START; |
| 235 | + reply[1U] = 0U; |
| 236 | + reply[2U] = CMD_GET_VERSION; |
| 237 | + reply[3U] = 0x01U; // protocol version |
| 238 | + reply[4U] = 0x02U; // CPU type (STM32) |
| 239 | + |
| 240 | + // 16-byte UDID |
| 241 | + memset(reply + 5U, 0x00U, 16U); |
| 242 | + getUid(reply + 5U); |
| 243 | + |
| 244 | + // HW description |
| 245 | + uint8_t count = 21; |
| 246 | + for (uint8_t i = 0U; i < sizeof(HARDWARE); i++, count++) |
| 247 | + reply[count] = HARDWARE[i]; |
| 248 | + |
| 249 | + // Total length |
| 250 | + reply[1U] = count; |
| 251 | + |
| 252 | + VCPWrite(reply, count); |
| 253 | +} |
| 254 | + |
219 | 255 | /** |
220 | 256 | * @brief Write a debug message to the USB port, using the DVMHost modem format |
221 | 257 | * |
|
0 commit comments