hp34comm: add support for boot keycode draft

Tue, 27 Oct 2020 21:48:28 +0100

author
David Douard <david.douard@sdf3.org>
date
Tue, 27 Oct 2020 21:48:28 +0100
changeset 39
63c6a720cb97
parent 38
ffef9bbb345d
child 40
069bbd5ee3e4

hp34comm: add support for boot keycode

src/hp34comm.cpp file | annotate | diff | comparison | revisions
src/hp34comm.h file | annotate | diff | comparison | revisions
--- a/src/hp34comm.cpp	Mon Oct 26 00:23:55 2020 +0100
+++ b/src/hp34comm.cpp	Tue Oct 27 21:48:28 2020 +0100
@@ -16,10 +16,11 @@
 #define RXTIMEOUT 50ms
 #define STARTUPRETRY 0.5
 
-const uint8_t startup_seq[] = {
+uint8_t startup_seq[] = {
   0x33,
   0x02,
   0x00,
+  0x00,  // to be replaced by the actual keycode, if any
 };
 
 HPSerial::statemethod HPSerial::state_table[NUM_STATES] = {
@@ -42,7 +43,12 @@
   serial.attach(callback(this, &HPSerial::rxIrq), SerialBase::RxIrq);
 }
 
-void HPSerial::startup(void) {
+void HPSerial::startup(uint8_t keycode) {
+  if (keycode != 0xFF) {
+      startup_sed[2] = 0xFF;
+      startup_sed[3] = keycode;
+  }
+
   cur_gstate = GSTATE_STARTING;
   set_timer(10ms); // launch the startup in 10ms
 }
@@ -50,20 +56,19 @@
 void HPSerial::_startup(void)
 {
   cur_gstate = GSTATE_STARTING;
-  tr_data.size = sizeof(startup_seq);
   tr_data.cmd = 0xFF;
   tr_data.pos = 0;
+
+  if (startup_seq[2] == 0xFF)
+      tr_data.size = 4;
+  else
+      tr_data.size = 3; // sizeof(startup_seq);
   for(uint8_t i=0; i<tr_data.size; i++)
     tr_data.payload[i] = startup_seq[i];
+
   cur_state = do_state_sending();
 }
 
-void HPSerial::send(const uint8_t *buf, uint8_t size)
-{
-  //  tx_data->
-  //send(startup, sizeof(startup)/sizeof(startup[0]));
-}
-
 void HPSerial::sendkey(uint8_t keycode)
 {
   tr_data.size = 2;
--- a/src/hp34comm.h	Mon Oct 26 00:23:55 2020 +0100
+++ b/src/hp34comm.h	Tue Oct 27 21:48:28 2020 +0100
@@ -30,8 +30,7 @@
   bool cmd_buf_full(void);
   unsigned int nerrors(uint8_t errorno);
 
-  void startup(void);
-  void send(const uint8_t *buf, uint8_t size);
+  void startup(uint8_t keycode=0xFF);
   void sendkey(uint8_t keycode);
 
 private:

mercurial