Reworking the AVR specific stuff into an AVRInterface class.
This commit is contained in:
@@ -24,7 +24,7 @@ CSerialPort avr;
|
||||
int avrOnPort = COM_NO_PORT; // Serial Port 1, 2, ... taking note that some USB adapters can be up toward channel 11, 12, ...
|
||||
unsigned avrBaud = 9600;
|
||||
|
||||
DWORD const retryInterval = 1000; // ms
|
||||
const uint32_t retryInterval = 1000; // ms
|
||||
|
||||
// Each DT is the hex-character from the stream
|
||||
//
|
||||
@@ -219,13 +219,13 @@ int DetachSerialPort();
|
||||
// @param[in] len is the count of bytes in the message
|
||||
// @returns true if the serial interface accepted it.
|
||||
//
|
||||
bool SerialSend(const uint8_t *p, DWORD len);
|
||||
bool SerialSend(const uint8_t *p, uint16_t len);
|
||||
|
||||
// Just big enough to hold an OSD message which is a 1 message command, 4 messages with text
|
||||
#define SERIALQUEUESIZE 5
|
||||
typedef struct {
|
||||
uint8_t *messageToSend;
|
||||
DWORD len;
|
||||
uint16_t len;
|
||||
} SerialQueue_T;
|
||||
|
||||
static SerialQueue_T serialQueue[SERIALQUEUESIZE];
|
||||
@@ -241,7 +241,7 @@ static int serialQueueCount = 0;
|
||||
// @param[in] len is the count of bytes in the message
|
||||
// @returns false if the queue (which is a fixed size) is full.
|
||||
//
|
||||
bool ProcessSerialQueue(const uint8_t *p = NULL, DWORD len = 0);
|
||||
bool ProcessSerialQueue(const uint8_t *p = NULL, uint16_t len = 0);
|
||||
|
||||
|
||||
// ProcessSerialReceive
|
||||
@@ -257,11 +257,11 @@ unsigned long Hex2Dec(uint8_t *p, int dig);
|
||||
void ShowAllStatusInfo();
|
||||
|
||||
bool UserWantsToExitCanSniff = false;
|
||||
DWORD progStartTime;
|
||||
DWORD progStartTime_ms;
|
||||
|
||||
typedef struct {
|
||||
const char *pMsg;
|
||||
DWORD MsgLen;
|
||||
uint16_t MsgLen;
|
||||
} Message_T;
|
||||
|
||||
typedef struct {
|
||||
@@ -531,11 +531,11 @@ void ProcessWindowsMessage(void) {
|
||||
void EmitBuffer(const char *prefix, const uint8_t *buf, size_t len = 0, bool appendReturn = false) {
|
||||
int i = 0;
|
||||
const char *p = (const char *)buf;
|
||||
DWORD now = timeGetTime();
|
||||
uint32_t now_ms = timeGetTime();
|
||||
char txtBuf[MAXTEXTLEN] = "";
|
||||
|
||||
if (len == 0) len = strlen((const char *)buf);
|
||||
sprintf_s(txtBuf, MAXTEXTLEN, "%7.3f: [%3d]%s", (float)(now - progStartTime)/1000.0f, (int)strlen(p), prefix);
|
||||
sprintf_s(txtBuf, MAXTEXTLEN, "%7.3f: [%3d]%s", (float)(now_ms - progStartTime_ms)/1000.0f, (int)strlen(p), prefix);
|
||||
Console_Write(txtBuf);
|
||||
while (*p && ((unsigned)(p - (const char *)buf) < len)) {
|
||||
if (isprint(*p)) {
|
||||
@@ -575,7 +575,7 @@ void EchoSerialRecv(const uint8_t *pMsg) {
|
||||
Console_ScrollBottomRegion();
|
||||
}
|
||||
|
||||
bool SerialSend(const uint8_t *p, DWORD len) {
|
||||
bool SerialSend(const uint8_t *p, uint16_t len) {
|
||||
bool retVal = false;
|
||||
Console_SetCursor(0, -1);
|
||||
EmitBuffer("> ", p, len);
|
||||
@@ -590,7 +590,7 @@ bool SerialSend(const uint8_t *p, DWORD len) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool ProcessSerialQueue(const uint8_t *p, DWORD len) {
|
||||
bool ProcessSerialQueue(const uint8_t *p, uint16_t len) {
|
||||
bool retVal = false; // assume fail
|
||||
static bool freshData = false;
|
||||
|
||||
@@ -920,7 +920,7 @@ int __cdecl main(int argc, char *argv[]) {
|
||||
short consoleHeight = 80;
|
||||
short consoleScrollHeight = 30;
|
||||
|
||||
progStartTime = timeGetTime();
|
||||
progStartTime_ms = timeGetTime();
|
||||
MessageHandlerSanityCheck(); // If the table is bad, we exit here
|
||||
UserCommandsSanityCheck(); // If the table is bad, we exit here
|
||||
|
||||
@@ -1174,7 +1174,7 @@ void EnumerateComPorts() {
|
||||
bool portFound = false;
|
||||
HANDLE port = CreateFile(cBuf, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if (port == INVALID_HANDLE_VALUE) {
|
||||
DWORD dwError = GetLastError();
|
||||
uint32_t dwError = GetLastError();
|
||||
if ((dwError == ERROR_ACCESS_DENIED) || (dwError == ERROR_GEN_FAILURE)
|
||||
|| (dwError == ERROR_SHARING_VIOLATION) || (dwError == ERROR_SEM_TIMEOUT)) {
|
||||
foundPorts++;
|
||||
@@ -1208,7 +1208,7 @@ int AttachToSerialPort() {
|
||||
char buf[20]; // generously sized.
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "\\\\.\\COM%d", avrOnPort);
|
||||
DWORD Access = GENERIC_WRITE | GENERIC_READ;
|
||||
uint32_t Access = GENERIC_WRITE | GENERIC_READ;
|
||||
if (avr.Open(buf, avrBaud, 8, NOPARITY, ONESTOPBIT, Access)) {
|
||||
success = true;
|
||||
avr.Set_RTS_State(false);
|
||||
|
||||
Reference in New Issue
Block a user