kopia lustrzana https://github.com/evil-mad/EggBot
feature/BinaryCommandTest
rodzic
87dbe2e370
commit
7759f5ff7f
Plik diff jest za duży
Load Diff
Plik binarny nie jest wyświetlany.
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -151,7 +151,7 @@ volatile UINT16 g_StepperDisableTimeoutS; // Seconds of no motion before m
|
|||
volatile UINT16 g_StepperDisableSecondCounter; // Counts milliseconds up to 1 s for stepper disable timeout
|
||||
volatile UINT16 g_StepperDisableCountdownS; // After motion is done, counts down in seconds from g_StepperDisableTimeoutS to zero
|
||||
|
||||
const rom char st_version[] = {"EBBv13_and_above EB Firmware Version 3.0.1"};
|
||||
const rom char st_version[] = {"EBBv13_and_above EB Firmware Version 3.0.1.1"};
|
||||
|
||||
#pragma udata ISR_buf = 0x100
|
||||
volatile unsigned int ISR_A_FIFO[16]; // Stores the most recent analog conversions
|
||||
|
@ -918,6 +918,11 @@ void ProcessIO(void)
|
|||
static BYTE last_fifo_size;
|
||||
static unsigned char button_state = 0;
|
||||
static unsigned int button_ctr = 0;
|
||||
static BOOL first_byte = TRUE; // True whenever we are looking for
|
||||
// the first byte of the next cmd
|
||||
static BYTE binary_bytes_left = 0; // When not zero, stores the number
|
||||
// of bytes left to copy over for
|
||||
// this binary command
|
||||
|
||||
BYTE i;
|
||||
BOOL done = FALSE;
|
||||
|
@ -976,70 +981,133 @@ void ProcessIO(void)
|
|||
{
|
||||
tst_char = g_RX_command_buf[byte_cnt];
|
||||
|
||||
if (binary_bytes_left)
|
||||
{
|
||||
g_RX_buf[g_RX_buf_in] = tst_char;
|
||||
g_RX_buf_in++;
|
||||
byte_cnt++;
|
||||
binary_bytes_left--;
|
||||
if (!binary_bytes_left)
|
||||
{
|
||||
if (bittstzero(TestMode)) // TEST_MODE_PARSING_COMMAND_NUM
|
||||
{
|
||||
LATCbits.LATC0 = 1;
|
||||
}
|
||||
parse_Y_packet();
|
||||
if (bittstzero(TestMode)) // TEST_MODE_PARSING_COMMAND_NUM
|
||||
{
|
||||
LATCbits.LATC0 = 0;
|
||||
}
|
||||
g_RX_buf_in = 0;
|
||||
g_RX_buf_out = 0;
|
||||
first_byte = TRUE;
|
||||
}
|
||||
}
|
||||
else if (first_byte)
|
||||
{
|
||||
// Check for binary command. If we see a 'Y' then we know we have a
|
||||
// binary command, and so we need to copy the right number of bytes
|
||||
// over to the binary command temp storage
|
||||
if (tst_char == 'Y')
|
||||
{
|
||||
first_byte = FALSE;
|
||||
binary_bytes_left = 28;
|
||||
|
||||
if ((rx_bytes - byte_cnt) >= 28u)
|
||||
{
|
||||
byte_cnt++; // Advance past the "Y"
|
||||
while (binary_bytes_left)
|
||||
{
|
||||
g_RX_buf[g_RX_buf_in] = g_RX_command_buf[byte_cnt];
|
||||
g_RX_buf_in++;
|
||||
byte_cnt++;
|
||||
binary_bytes_left--;
|
||||
}
|
||||
if (bittstzero(TestMode)) // TEST_MODE_PARSING_COMMAND_NUM
|
||||
{
|
||||
LATCbits.LATC0 = 1;
|
||||
}
|
||||
parse_Y_packet();
|
||||
if (bittstzero(TestMode)) // TEST_MODE_PARSING_COMMAND_NUM
|
||||
{
|
||||
LATCbits.LATC0 = 0;
|
||||
}
|
||||
g_RX_buf_in = 0;
|
||||
g_RX_buf_out = 0;
|
||||
first_byte = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bittst(TestMode, TEST_MODE_USART_COMMAND_NUM))
|
||||
{
|
||||
Write1USART(tst_char);
|
||||
}
|
||||
|
||||
// Check to see if we are in a CR/LF situation
|
||||
if (
|
||||
!in_cr
|
||||
&&
|
||||
(
|
||||
kCR == tst_char
|
||||
||
|
||||
kLF == tst_char
|
||||
)
|
||||
)
|
||||
{
|
||||
in_cr = TRUE;
|
||||
g_RX_buf[g_RX_buf_in] = kCR;
|
||||
g_RX_buf_in++;
|
||||
|
||||
// At this point, we know we have a full packet
|
||||
// of information from the PC to parse
|
||||
if (!binary_bytes_left)
|
||||
{
|
||||
// Check to see if we are in a CR/LF situation
|
||||
if (
|
||||
!in_cr
|
||||
&&
|
||||
(
|
||||
kCR == tst_char
|
||||
||
|
||||
kLF == tst_char
|
||||
)
|
||||
)
|
||||
{
|
||||
in_cr = TRUE;
|
||||
g_RX_buf[g_RX_buf_in] = kCR;
|
||||
g_RX_buf_in++;
|
||||
|
||||
// Now, if we've gotten a full command (user send <CR>) then
|
||||
// go call the code that deals with that command, and then
|
||||
// keep parsing. (This allows multiple small commands per packet)
|
||||
if (bittstzero(TestMode)) // TEST_MODE_PARSING_COMMAND_NUM
|
||||
{
|
||||
LATCbits.LATC0 = 1;
|
||||
// At this point, we know we have a full packet
|
||||
// of information from the PC to parse
|
||||
|
||||
// Now, if we've gotten a full command (user send <CR>) then
|
||||
// go call the code that deals with that command, and then
|
||||
// keep parsing. (This allows multiple small commands per packet)
|
||||
if (bittstzero(TestMode)) // TEST_MODE_PARSING_COMMAND_NUM
|
||||
{
|
||||
LATCbits.LATC0 = 1;
|
||||
}
|
||||
parse_packet();
|
||||
if (bittstzero(TestMode)) // TEST_MODE_PARSING_COMMAND_NUM
|
||||
{
|
||||
LATCbits.LATC0 = 0;
|
||||
}
|
||||
g_RX_buf_in = 0;
|
||||
g_RX_buf_out = 0;
|
||||
first_byte = TRUE;
|
||||
}
|
||||
parse_packet();
|
||||
if (bittstzero(TestMode)) // TEST_MODE_PARSING_COMMAND_NUM
|
||||
else if (tst_char == 8u && g_RX_buf_in > 0u)
|
||||
{
|
||||
LATCbits.LATC0 = 0;
|
||||
// Handle the backspace thing
|
||||
g_RX_buf_in--;
|
||||
g_RX_buf[g_RX_buf_in] = 0x00;
|
||||
ebb_print((far rom char *)" \b");
|
||||
}
|
||||
else if (
|
||||
tst_char != kCR
|
||||
&&
|
||||
tst_char != kLF
|
||||
&&
|
||||
tst_char >= 32u
|
||||
)
|
||||
{
|
||||
// Only add a byte if it is not a CR or LF
|
||||
g_RX_buf[g_RX_buf_in] = tst_char;
|
||||
in_cr = FALSE;
|
||||
first_byte = FALSE;
|
||||
g_RX_buf_in++;
|
||||
}
|
||||
// Check for buffer wraparound
|
||||
if (kRX_BUF_SIZE == g_RX_buf_in)
|
||||
{
|
||||
bitset(error_byte, kERROR_BYTE_RX_BUFFER_OVERRUN);
|
||||
g_RX_buf_in = 0;
|
||||
g_RX_buf_out = 0;
|
||||
}
|
||||
g_RX_buf_in = 0;
|
||||
g_RX_buf_out = 0;
|
||||
}
|
||||
else if (tst_char == 8u && g_RX_buf_in > 0u)
|
||||
{
|
||||
// Handle the backspace thing
|
||||
g_RX_buf_in--;
|
||||
g_RX_buf[g_RX_buf_in] = 0x00;
|
||||
ebb_print((far rom char *)" \b");
|
||||
}
|
||||
else if (
|
||||
tst_char != kCR
|
||||
&&
|
||||
tst_char != kLF
|
||||
&&
|
||||
tst_char >= 32u
|
||||
)
|
||||
{
|
||||
// Only add a byte if it is not a CR or LF
|
||||
g_RX_buf[g_RX_buf_in] = tst_char;
|
||||
in_cr = FALSE;
|
||||
g_RX_buf_in++;
|
||||
}
|
||||
// Check for buffer wraparound
|
||||
if (kRX_BUF_SIZE == g_RX_buf_in)
|
||||
{
|
||||
bitset(error_byte, kERROR_BYTE_RX_BUFFER_OVERRUN);
|
||||
g_RX_buf_in = 0;
|
||||
g_RX_buf_out = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4606,3 +4606,78 @@ void parse_CS_packet(void)
|
|||
|
||||
print_line_ending(kLE_OK_NORM);
|
||||
}
|
||||
|
||||
void parse_Y_packet(void)
|
||||
{
|
||||
UINT32 tmp;
|
||||
|
||||
// We should now have
|
||||
// AAAABBBBCCCCDDDDEEEEFFFFGGGG
|
||||
// in g_RX_buf[] starting at g_RX_buf_out
|
||||
//
|
||||
// T3 command
|
||||
// T3,Intervals,Rate1,Accel1,Jerk1,Rate2,Accel2,Jerk2[,Clear]
|
||||
// Intervals = unsigned 32 bit
|
||||
// Rate = signed 32
|
||||
// Accel = signed 32 bit
|
||||
// Jerk = signed 32 bit
|
||||
// Clear = 2 bits
|
||||
//
|
||||
// A = Intervals
|
||||
// B = Rate1
|
||||
// C = Accel1
|
||||
// D = Jerk1
|
||||
// E = Rate2
|
||||
// F = Accel2
|
||||
// G = Jerk2
|
||||
// For the Clear parameter, Y command should assume NEVER clear accumulators.
|
||||
// YAAAABBBBCCCCDDDDEEEEFFFFGGGG
|
||||
// 1 bytes command
|
||||
// 28 bytes data
|
||||
// No carriage return
|
||||
|
||||
// For now, just print out all of the parameters to the debug UART
|
||||
tmp = g_RX_buf[0];
|
||||
tmp = (tmp << 8) | g_RX_buf[1];
|
||||
tmp = (tmp << 8) | g_RX_buf[2];
|
||||
tmp = (tmp << 8) | g_RX_buf[3];
|
||||
HexPrint(tmp);
|
||||
|
||||
tmp = g_RX_buf[4];
|
||||
tmp = (tmp << 8) | g_RX_buf[5];
|
||||
tmp = (tmp << 8) | g_RX_buf[6];
|
||||
tmp = (tmp << 8) | g_RX_buf[7];
|
||||
HexPrint(tmp);
|
||||
|
||||
tmp = g_RX_buf[8];
|
||||
tmp = (tmp << 8) | g_RX_buf[9];
|
||||
tmp = (tmp << 8) | g_RX_buf[10];
|
||||
tmp = (tmp << 8) | g_RX_buf[11];
|
||||
HexPrint(tmp);
|
||||
|
||||
tmp = g_RX_buf[12];
|
||||
tmp = (tmp << 8) | g_RX_buf[13];
|
||||
tmp = (tmp << 8) | g_RX_buf[14];
|
||||
tmp = (tmp << 8) | g_RX_buf[15];
|
||||
HexPrint(tmp);
|
||||
|
||||
tmp = g_RX_buf[16];
|
||||
tmp = (tmp << 8) | g_RX_buf[17];
|
||||
tmp = (tmp << 8) | g_RX_buf[18];
|
||||
tmp = (tmp << 8) | g_RX_buf[19];
|
||||
HexPrint(tmp);
|
||||
|
||||
tmp = g_RX_buf[20];
|
||||
tmp = (tmp << 8) | g_RX_buf[21];
|
||||
tmp = (tmp << 8) | g_RX_buf[22];
|
||||
tmp = (tmp << 8) | g_RX_buf[23];
|
||||
HexPrint(tmp);
|
||||
|
||||
tmp = g_RX_buf[24];
|
||||
tmp = (tmp << 8) | g_RX_buf[25];
|
||||
tmp = (tmp << 8) | g_RX_buf[26];
|
||||
tmp = (tmp << 8) | g_RX_buf[27];
|
||||
HexPrint(tmp);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -396,6 +396,7 @@ void parse_L3_packet(void);
|
|||
void parse_CM_packet(void);
|
||||
void parse_TR_packet(void);
|
||||
void parse_TD_packet(void);
|
||||
void parse_Y_packet(void);
|
||||
void EBB_Init(void);
|
||||
void process_SP(PenStateType NewState, UINT16 CommandDuration);
|
||||
UINT8 process_QM(void);
|
||||
|
|
Ładowanie…
Reference in New Issue