From e09fe7d42f652737fb8b31ba8d9a17eb78e91f01 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Thu, 9 Mar 2023 21:51:29 -0500 Subject: [PATCH] McopySerial now has a confirm() method which marks the end of a command. This is a wrapper around Serial.println() --- ino/lib/McopySerial/McopySerial.cpp | 6 ++++++ ino/lib/McopySerial/McopySerial.h | 3 +++ ino/mcopy_cam_canon/McopySerial.cpp | 6 ++++++ ino/mcopy_cam_canon/McopySerial.h | 3 +++ 4 files changed, 18 insertions(+) diff --git a/ino/lib/McopySerial/McopySerial.cpp b/ino/lib/McopySerial/McopySerial.cpp index 695c7d0..c849017 100644 --- a/ino/lib/McopySerial/McopySerial.cpp +++ b/ino/lib/McopySerial/McopySerial.cpp @@ -8,6 +8,8 @@ McopySerial::McopySerial (char identity) { void McopySerial::begin () { Serial.begin(baud); + Serial.flush(); + Serial.setTimeout(serialDelay); } char McopySerial::loop () { @@ -52,6 +54,10 @@ void McopySerial::debug (bool state) { debugOn = state; } +void McopySerial::confirm (char cmd) { + Serial.println(cmd); +} + void McopySerial::log (String message) { if (debugOn) { Serial.println(message); diff --git a/ino/lib/McopySerial/McopySerial.h b/ino/lib/McopySerial/McopySerial.h index 60cf25b..4e89a0a 100644 --- a/ino/lib/McopySerial/McopySerial.h +++ b/ino/lib/McopySerial/McopySerial.h @@ -6,6 +6,8 @@ class McopySerial { private: + const int serialDelay = 5; + volatile int baud = 57600; volatile bool debugOn = false; volatile char cmdChar = 'z'; @@ -67,6 +69,7 @@ class McopySerial { void setBaud(int baudRate); void setIdentity(char identity); char loop(); + void confirm(char cmd); void debug (bool state); void log (String message); diff --git a/ino/mcopy_cam_canon/McopySerial.cpp b/ino/mcopy_cam_canon/McopySerial.cpp index 695c7d0..c849017 100644 --- a/ino/mcopy_cam_canon/McopySerial.cpp +++ b/ino/mcopy_cam_canon/McopySerial.cpp @@ -8,6 +8,8 @@ McopySerial::McopySerial (char identity) { void McopySerial::begin () { Serial.begin(baud); + Serial.flush(); + Serial.setTimeout(serialDelay); } char McopySerial::loop () { @@ -52,6 +54,10 @@ void McopySerial::debug (bool state) { debugOn = state; } +void McopySerial::confirm (char cmd) { + Serial.println(cmd); +} + void McopySerial::log (String message) { if (debugOn) { Serial.println(message); diff --git a/ino/mcopy_cam_canon/McopySerial.h b/ino/mcopy_cam_canon/McopySerial.h index 60cf25b..4e89a0a 100644 --- a/ino/mcopy_cam_canon/McopySerial.h +++ b/ino/mcopy_cam_canon/McopySerial.h @@ -6,6 +6,8 @@ class McopySerial { private: + const int serialDelay = 5; + volatile int baud = 57600; volatile bool debugOn = false; volatile char cmdChar = 'z'; @@ -67,6 +69,7 @@ class McopySerial { void setBaud(int baudRate); void setIdentity(char identity); char loop(); + void confirm(char cmd); void debug (bool state); void log (String message);