1
0
mirror of https://github.com/halleysfifthinc/Toyota-AVC-LAN synced 2025-06-07 16:06:12 +00:00

Indent case labels

This commit is contained in:
Allen Hill 2023-08-19 21:41:45 -04:00
parent c07083423f
commit 48b20a9c5c
3 changed files with 161 additions and 160 deletions

View File

@ -3,4 +3,5 @@ BasedOnStyle: LLVM
UseCRLF: false
BreakBeforeBraces: Attach
AllowShortBlocksOnASingleLine: Empty
IndentCaseLabels: true
...

View File

@ -759,69 +759,69 @@ byte AVCLan_SendAnswer() {
byte r = 0;
switch (answerReq) {
case cmStatus1:
r = AVCLan_SendAnswerFrame((byte *)CMD_STATUS1);
break;
case cmStatus2:
r = AVCLan_SendAnswerFrame((byte *)CMD_STATUS2);
break;
case cmStatus3:
r = AVCLan_SendAnswerFrame((byte *)CMD_STATUS3);
break;
case cmStatus4:
r = AVCLan_SendAnswerFrame((byte *)CMD_STATUS4);
break;
case cmRegister:
r = AVCLan_SendAnswerFrame((byte *)CMD_REGISTER);
break;
case cmInit: // RS232_Print("INIT\n");
r = AVCLan_SendInitCommands();
break;
case cmCheck:
r = AVCLan_SendAnswerFrame((byte *)CMD_CHECK);
check_timeout = 0;
CMD_CHECK[6]++;
RS232_Print("AVCCHK\n");
break;
case cmPlayReq1:
playMode = 0;
r = AVCLan_SendAnswerFrame((byte *)CMD_PLAY_OK1);
break;
case cmPlayReq2:
case cmPlayReq3:
playMode = 0;
r = AVCLan_SendAnswerFrame((byte *)CMD_PLAY_OK2);
if (!r)
r = AVCLan_SendAnswerFrame((byte *)CMD_PLAY_OK3);
CD_Mode = stPlay;
break;
case cmPlayIt:
playMode = 1;
RS232_Print("PLAY\n");
CMD_PLAY_OK4[7] = cd_Disc;
CMD_PLAY_OK4[8] = cd_Track;
CMD_PLAY_OK4[9] = cd_Time_Min;
CMD_PLAY_OK4[10] = cd_Time_Sec;
r = AVCLan_SendAnswerFrame((byte *)CMD_PLAY_OK4);
if (!r)
AVCLan_Send_Status();
CD_Mode = stPlay;
break;
case cmStopReq:
case cmStopReq2:
CD_Mode = stStop;
playMode = 0;
case cmStatus1:
r = AVCLan_SendAnswerFrame((byte *)CMD_STATUS1);
break;
case cmStatus2:
r = AVCLan_SendAnswerFrame((byte *)CMD_STATUS2);
break;
case cmStatus3:
r = AVCLan_SendAnswerFrame((byte *)CMD_STATUS3);
break;
case cmStatus4:
r = AVCLan_SendAnswerFrame((byte *)CMD_STATUS4);
break;
case cmRegister:
r = AVCLan_SendAnswerFrame((byte *)CMD_REGISTER);
break;
case cmInit: // RS232_Print("INIT\n");
r = AVCLan_SendInitCommands();
break;
case cmCheck:
r = AVCLan_SendAnswerFrame((byte *)CMD_CHECK);
check_timeout = 0;
CMD_CHECK[6]++;
RS232_Print("AVCCHK\n");
break;
case cmPlayReq1:
playMode = 0;
r = AVCLan_SendAnswerFrame((byte *)CMD_PLAY_OK1);
break;
case cmPlayReq2:
case cmPlayReq3:
playMode = 0;
r = AVCLan_SendAnswerFrame((byte *)CMD_PLAY_OK2);
if (!r)
r = AVCLan_SendAnswerFrame((byte *)CMD_PLAY_OK3);
CD_Mode = stPlay;
break;
case cmPlayIt:
playMode = 1;
RS232_Print("PLAY\n");
CMD_PLAY_OK4[7] = cd_Disc;
CMD_PLAY_OK4[8] = cd_Track;
CMD_PLAY_OK4[9] = cd_Time_Min;
CMD_PLAY_OK4[10] = cd_Time_Sec;
r = AVCLan_SendAnswerFrame((byte *)CMD_PLAY_OK4);
if (!r)
AVCLan_Send_Status();
CD_Mode = stPlay;
break;
case cmStopReq:
case cmStopReq2:
CD_Mode = stStop;
playMode = 0;
r = AVCLan_SendAnswerFrame((byte *)CMD_STOP1);
CMD_STOP2[7] = cd_Disc;
CMD_STOP2[8] = cd_Track;
CMD_STOP2[9] = cd_Time_Min;
CMD_STOP2[10] = cd_Time_Sec;
r = AVCLan_SendAnswerFrame((byte *)CMD_STOP2);
break;
case cmBeep:
AVCLan_SendAnswerFrame((byte *)CMD_BEEP);
break;
r = AVCLan_SendAnswerFrame((byte *)CMD_STOP1);
CMD_STOP2[7] = cd_Disc;
CMD_STOP2[8] = cd_Track;
CMD_STOP2[9] = cd_Time_Min;
CMD_STOP2[10] = cd_Time_Sec;
r = AVCLan_SendAnswerFrame((byte *)CMD_STOP2);
break;
case cmBeep:
AVCLan_SendAnswerFrame((byte *)CMD_BEEP);
break;
}
answerReq = cmNull;

196
sniffer.c
View File

@ -71,10 +71,10 @@ int main() {
// HandleEvent
switch (Event) {
case EV_STATUS:
Event &= ~EV_STATUS;
AVCLan_Send_Status();
break;
case EV_STATUS:
Event &= ~EV_STATUS;
AVCLan_Send_Status();
break;
}
// Key handler
@ -87,109 +87,109 @@ int main() {
RS232_RxCharBegin = RS232_RxCharEnd = 0; // reset Buffer
sbi(USART0.CTRLA, USART_RXCIE_bp); // enable RX complete interrupt
switch (readkey) {
case 'S':
showLog = 0;
RS232_Print("READ SEQUENCE > \n");
readSeq = 1;
s_len = 0;
s_dig = 0;
s_c[0] = s_c[1] = 0;
break;
case 'W':
showLog = 1;
readSeq = 0;
AVCLan_SendMyData(data_tmp, s_len);
break;
case 'Q':
showLog = 1;
readSeq = 0;
AVCLan_SendMyDataBroadcast(data_tmp, s_len);
break;
case 'R':
RS232_Print("REGIST:\n");
AVCLan_Command(cmRegister);
TCB1.CNT = 0;
while (TCB1.CNT < 540) {}
CHECK_AVC_LINE;
break;
case 'r':
AVCLan_Register();
break;
case 'l':
RS232_Print("Log OFF\n");
showLog = 0;
break;
case 'L':
RS232_Print("Log ON\n");
showLog = 1;
break;
case 'k':
RS232_Print("str OFF\n");
showLog2 = 0;
break;
case 'K':
RS232_Print("str ON\n");
showLog2 = 1;
break;
case 'B':
data_tmp[0] = 0x00;
data_tmp[1] = 0x5E;
data_tmp[2] = 0x29;
data_tmp[3] = 0x60;
data_tmp[4] = 0x01;
s_len = 5;
AVCLan_SendMyData(data_tmp, s_len);
break;
case 'S':
showLog = 0;
RS232_Print("READ SEQUENCE > \n");
readSeq = 1;
s_len = 0;
s_dig = 0;
s_c[0] = s_c[1] = 0;
break;
case 'W':
showLog = 1;
readSeq = 0;
AVCLan_SendMyData(data_tmp, s_len);
break;
case 'Q':
showLog = 1;
readSeq = 0;
AVCLan_SendMyDataBroadcast(data_tmp, s_len);
break;
case 'R':
RS232_Print("REGIST:\n");
AVCLan_Command(cmRegister);
TCB1.CNT = 0;
while (TCB1.CNT < 540) {}
CHECK_AVC_LINE;
break;
case 'r':
AVCLan_Register();
break;
case 'l':
RS232_Print("Log OFF\n");
showLog = 0;
break;
case 'L':
RS232_Print("Log ON\n");
showLog = 1;
break;
case 'k':
RS232_Print("str OFF\n");
showLog2 = 0;
break;
case 'K':
RS232_Print("str ON\n");
showLog2 = 1;
break;
case 'B':
data_tmp[0] = 0x00;
data_tmp[1] = 0x5E;
data_tmp[2] = 0x29;
data_tmp[3] = 0x60;
data_tmp[4] = 0x01;
s_len = 5;
AVCLan_SendMyData(data_tmp, s_len);
break;
#ifdef HARDWARE_DEBUG
case '1':
SetHighLow();
break;
case 'E':
if (INPUT_IS_SET) {
RS232_Print("Set/High/1\n");
} else if (INPUT_IS_CLEAR) {
RS232_Print("Unset/Low/0\n");
} else {
RS232_Print("WTF?\n");
}
break;
case '1':
SetHighLow();
break;
case 'E':
if (INPUT_IS_SET) {
RS232_Print("Set/High/1\n");
} else if (INPUT_IS_CLEAR) {
RS232_Print("Unset/Low/0\n");
} else {
RS232_Print("WTF?\n");
}
break;
#endif
#ifdef SOFTWARE_DEBUG
case 'M':
AVCLan_Measure();
break;
case 'M':
AVCLan_Measure();
break;
#endif
default:
if (readSeq == 1) {
s_c[s_dig] = readkey;
default:
if (readSeq == 1) {
s_c[s_dig] = readkey;
s_dig++;
if (s_dig == 2) {
if (s_c[0] < ':')
s_c[0] -= 48;
else
s_c[0] -= 55;
data_tmp[s_len] = 16 * s_c[0];
if (s_c[1] < ':')
s_c[1] -= 48;
else
s_c[1] -= 55;
data_tmp[s_len] += s_c[1];
s_len++;
s_dig = 0;
s_c[0] = s_c[1] = 0;
}
if (showLog2) {
RS232_Print("CURRENT SEQUENCE > ");
for (i = 0; i < s_len; i++) {
RS232_PrintHex8(data_tmp[i]);
RS232_SendByte(' ');
s_dig++;
if (s_dig == 2) {
if (s_c[0] < ':')
s_c[0] -= 48;
else
s_c[0] -= 55;
data_tmp[s_len] = 16 * s_c[0];
if (s_c[1] < ':')
s_c[1] -= 48;
else
s_c[1] -= 55;
data_tmp[s_len] += s_c[1];
s_len++;
s_dig = 0;
s_c[0] = s_c[1] = 0;
}
if (showLog2) {
RS232_Print("CURRENT SEQUENCE > ");
for (i = 0; i < s_len; i++) {
RS232_PrintHex8(data_tmp[i]);
RS232_SendByte(' ');
}
RS232_Print("\n");
}
RS232_Print("\n");
}
}
} // switch (readkey)
} // if (RS232_RxCharEnd)
}