Commit c6ec8cf0 authored by Jake Read's avatar Jake Read
Browse files

new bus-drop code

parent 073f103c
......@@ -151,7 +151,6 @@ void setup() {
ERRLIGHT_SETUP;
CLKLIGHT_SETUP;
DEBUG1PIN_SETUP;
// limit switch
//limitSetup();
// osap
......@@ -183,14 +182,12 @@ uint8_t testRx[256];
void loop() {
osapLoop();
stepper_hw->dacRefresh();
/*
// still not sure: this registers as "made" on init (?)
if(limitIsMade()){
ERRLIGHT_ON;
} else {
ERRLIGHT_OFF;
}
*/
} // end loop
......
Subproject commit eeabe1a173dc1c7270b0099a7a1a0e0e7735e1be
Subproject commit 50426e4ff771eeb2c94180e59a05258d2daf24ff
#include "syserror.h"
#include "indicators.h"
#include "osape-d51/osape/osap/ts.h"
#include "osape-d51/vertices/ucBusDrop.h"
#include "osape-d51/osape/utils/cobs.h"
#include "config.h"
#include "indicators.h"
uint8_t errBuf[1028];
uint8_t errEncoded[1028];
/*
boolean writeString(unsigned char* dest, uint16_t* dptr, String msg){
uint16_t len = msg.length();
dest[(*dptr) ++] = TS_STRING_KEY;
writeLenBytes(dest, dptr, len);
msg.getBytes(dest, len + 1);
return true;
volatile unsigned long errLightLastOn = 0;
volatile unsigned long errLightOnTime = 0;
volatile boolean errLightBlink = true;
volatile boolean errLightOn = false;
void sysErrLightFlash(uint8_t level){
ERRLIGHT_ON;
errLightOn = true;
errLightLastOn = millis();
switch(level){
case 0:
errLightBlink = false;
break;
case 1:
errLightOnTime = 5000;
break;
case 2:
errLightOnTime = 1000;
break;
case 3:
errLightOnTime = 250;
break;
}
}
void sysErrLightCheck(void){
if(errLightOn && errLightBlink){
if(errLightLastOn + errLightOnTime < millis()){
ERRLIGHT_OFF;
errLightOn = false;
}
}
}
boolean writeLenBytes(unsigned char* dest, uint16_t* dptr, uint16_t len){
dest[(*dptr) ++] = len;
dest[(*dptr) ++] = (len >> 8) & 255;
return true;
#ifdef UCBUS_IS_DROP
void sysError(String msg){
// noop
}
*/
#else
// config-your-own-ll-escape-hatch
void sysError(String msg){
......@@ -38,11 +65,18 @@ void sysError(String msg){
errBuf[6] = (len >> 24) & 255;
msg.getBytes(&(errBuf[7]), len + 1);
size_t ecl = cobsEncode(errBuf, len + 7, errEncoded);
errEncoded[ecl] = 0; // add delimiter
// escape:
Serial.write(errEncoded, ecl + 1);
errEncoded[ecl] = 0;
// direct escape
//if(Serial.availableForWrite() > (int64_t)ecl){
Serial.write(errEncoded, ecl + 1);
//Serial.flush();
//} else {
// ERRLIGHT_ON;
//}
}
#endif
void logPacket(uint8_t* pck, uint16_t len){
String errmsg;
errmsg.reserve(1024);
......@@ -53,4 +87,5 @@ void logPacket(uint8_t* pck, uint16_t len){
errmsg += ", ";
}
sysError(errmsg);
}
\ No newline at end of file
}
......@@ -7,4 +7,9 @@ void sysError(String msg);
void logPacket(uint8_t* pck, uint16_t len);
//void sysError(uint8_t* bytes, uint16_t len);
void sysErrLightFlash(uint8_t level);
void sysErrLightCheck(void);
#define ERROR(level, msg) sysErrLightFlash(level); sysError(msg)
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment