|
|
@ -70,7 +70,7 @@ telnetUnwrap(serbridgeConnData *conn, uint8_t *inBuf, int len) |
|
|
|
else uart0_write_char(c); // regular char
|
|
|
|
else uart0_write_char(c); // regular char
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case TN_iac: |
|
|
|
case TN_iac: |
|
|
|
os_printf("Telnet: IAC + %d\n", c); |
|
|
|
//os_printf("Telnet: IAC + %d\n", c);
|
|
|
|
switch (c) { |
|
|
|
switch (c) { |
|
|
|
case IAC: // second escape -> write one to outbuf and go normal again
|
|
|
|
case IAC: // second escape -> write one to outbuf and go normal again
|
|
|
|
state = TN_normal; |
|
|
|
state = TN_normal; |
|
|
@ -118,13 +118,13 @@ telnetUnwrap(serbridgeConnData *conn, uint8_t *inBuf, int len) |
|
|
|
case DTR_ON: |
|
|
|
case DTR_ON: |
|
|
|
if (mcu_reset_pin >= 0) { |
|
|
|
if (mcu_reset_pin >= 0) { |
|
|
|
#ifdef SERBR_DBG |
|
|
|
#ifdef SERBR_DBG |
|
|
|
os_printf("MCU reset gpio%d\n", mcu_reset_pin); |
|
|
|
os_printf("Telnet: reset gpio%d\n", mcu_reset_pin); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
GPIO_OUTPUT_SET(mcu_reset_pin, 0); |
|
|
|
GPIO_OUTPUT_SET(mcu_reset_pin, 0); |
|
|
|
os_delay_us(100L); |
|
|
|
os_delay_us(100L); |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef SERBR_DBG |
|
|
|
#ifdef SERBR_DBG |
|
|
|
else { os_printf("MCU reset: no pin\n"); } |
|
|
|
else { os_printf("Telnet: reset: no pin\n"); } |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
break; |
|
|
|
break; |
|
|
|
case DTR_OFF: |
|
|
|
case DTR_OFF: |
|
|
@ -136,18 +136,21 @@ telnetUnwrap(serbridgeConnData *conn, uint8_t *inBuf, int len) |
|
|
|
case RTS_ON: |
|
|
|
case RTS_ON: |
|
|
|
if (mcu_isp_pin >= 0) { |
|
|
|
if (mcu_isp_pin >= 0) { |
|
|
|
#ifdef SERBR_DBG |
|
|
|
#ifdef SERBR_DBG |
|
|
|
os_printf("MCU ISP gpio%d\n", mcu_isp_pin); |
|
|
|
os_printf("Telnet: ISP gpio%d LOW\n", mcu_isp_pin); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
GPIO_OUTPUT_SET(mcu_isp_pin, 0); |
|
|
|
GPIO_OUTPUT_SET(mcu_isp_pin, 0); |
|
|
|
os_delay_us(100L); |
|
|
|
os_delay_us(100L); |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef SERBR_DBG |
|
|
|
#ifdef SERBR_DBG |
|
|
|
else { os_printf("MCU isp: no pin\n"); } |
|
|
|
else { os_printf("Telnet: isp: no pin\n"); } |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
in_mcu_flashing++; |
|
|
|
in_mcu_flashing++; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RTS_OFF: |
|
|
|
case RTS_OFF: |
|
|
|
if (mcu_isp_pin >= 0) { |
|
|
|
if (mcu_isp_pin >= 0) { |
|
|
|
|
|
|
|
#ifdef SERBR_DBG |
|
|
|
|
|
|
|
os_printf("Telnet: ISP gpio%d HIGH\n", mcu_isp_pin); |
|
|
|
|
|
|
|
#endif |
|
|
|
GPIO_OUTPUT_SET(mcu_isp_pin, 1); |
|
|
|
GPIO_OUTPUT_SET(mcu_isp_pin, 1); |
|
|
|
os_delay_us(100L); |
|
|
|
os_delay_us(100L); |
|
|
|
} |
|
|
|
} |
|
|
@ -159,9 +162,9 @@ telnetUnwrap(serbridgeConnData *conn, uint8_t *inBuf, int len) |
|
|
|
case TN_setDataSize: |
|
|
|
case TN_setDataSize: |
|
|
|
if (c >= 5 && c <= 8) { |
|
|
|
if (c >= 5 && c <= 8) { |
|
|
|
flashConfig.data_bits = c - 5 + FIVE_BITS; |
|
|
|
flashConfig.data_bits = c - 5 + FIVE_BITS; |
|
|
|
uint32_t conf0 = CALC_UARTMODE(flashConfig.data_bits, flashConfig.parity, flashConfig.stop_bits); |
|
|
|
uart0_config(flashConfig.data_bits, flashConfig.parity, flashConfig.stop_bits); |
|
|
|
uart_config(0, flashConfig.baud_rate, conf0); |
|
|
|
|
|
|
|
configSave(); |
|
|
|
configSave(); |
|
|
|
|
|
|
|
os_printf("Telnet: %d bits/char\n", c); |
|
|
|
} else if (c == 0) { |
|
|
|
} else if (c == 0) { |
|
|
|
// data size of zero means we need to send the current data size
|
|
|
|
// data size of zero means we need to send the current data size
|
|
|
|
char respBuf[7] = { IAC, SB, ComPortOpt, SetDataSize, |
|
|
|
char respBuf[7] = { IAC, SB, ComPortOpt, SetDataSize, |
|
|
@ -179,6 +182,7 @@ telnetUnwrap(serbridgeConnData *conn, uint8_t *inBuf, int len) |
|
|
|
uart0_baud(tn_baud); |
|
|
|
uart0_baud(tn_baud); |
|
|
|
flashConfig.baud_rate = tn_baud; |
|
|
|
flashConfig.baud_rate = tn_baud; |
|
|
|
configSave(); |
|
|
|
configSave(); |
|
|
|
|
|
|
|
os_printf("Telnet: %d baud\n", tn_baud); |
|
|
|
} else if (tn_baud == 0) { |
|
|
|
} else if (tn_baud == 0) { |
|
|
|
// baud rate of zero means we need to send the baud rate
|
|
|
|
// baud rate of zero means we need to send the baud rate
|
|
|
|
uint32_t b = flashConfig.baud_rate; |
|
|
|
uint32_t b = flashConfig.baud_rate; |
|
|
@ -202,9 +206,9 @@ telnetUnwrap(serbridgeConnData *conn, uint8_t *inBuf, int len) |
|
|
|
if (c == 2) parity = ODD_BITS; |
|
|
|
if (c == 2) parity = ODD_BITS; |
|
|
|
if (c == 3) parity = EVEN_BITS; |
|
|
|
if (c == 3) parity = EVEN_BITS; |
|
|
|
flashConfig.parity = parity; |
|
|
|
flashConfig.parity = parity; |
|
|
|
uint32_t conf0 = CALC_UARTMODE(flashConfig.data_bits, flashConfig.parity, flashConfig.stop_bits); |
|
|
|
//uart0_config(flashConfig.data_bits, flashConfig.parity, flashConfig.stop_bits);
|
|
|
|
uart_config(0, flashConfig.baud_rate, conf0); |
|
|
|
|
|
|
|
configSave(); |
|
|
|
configSave(); |
|
|
|
|
|
|
|
os_printf("Telnet: parity %s\n", c==2?"odd":c==3?"even":"none"); |
|
|
|
state = TN_end; |
|
|
|
state = TN_end; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|