viacuda: add receiving of ADB packets.

This commit is contained in:
Maxim Poliakovski 2020-03-05 01:12:27 +01:00
parent 71d6966a03
commit 94cf232b5e
2 changed files with 28 additions and 0 deletions

View File

@ -248,6 +248,7 @@ void ViaCuda::process_packet()
switch (this->in_buf[0]) {
case CUDA_PKT_ADB:
LOG_F(9, "Cuda: ADB packet received \n");
process_adb_command(this->in_buf[1], this->in_count - 2);
break;
case CUDA_PKT_PSEUDO:
LOG_F(9, "Cuda: pseudo command packet received \n");
@ -263,6 +264,32 @@ void ViaCuda::process_packet()
}
}
void ViaCuda::process_adb_command(uint8_t cmd_byte, int data_count)
{
int cmd = cmd_byte & 0xF;
if(!cmd) {
LOG_F(9, "Cuda: ADB SendReset command requested\n");
response_header(CUDA_PKT_ADB, 0);
}
else if (cmd == 1) {
LOG_F(9, "Cuda: ADB Flush command requested\n");
response_header(CUDA_PKT_ADB, 0);
}
else if ((cmd & 0xC) == 8) {
LOG_F(9, "Cuda: ADB Listen command requested\n");
response_header(CUDA_PKT_ADB, 0);
}
else if ((cmd & 0xC) == 0xC) {
LOG_F(9, "Cuda: ADB Talk command requested\n");
response_header(CUDA_PKT_ADB, 0);
}
else {
LOG_F(ERROR, "Cuda: unsupported ADB command 0x%x \n", cmd);
error_response(CUDA_ERR_BAD_CMD);
}
}
void ViaCuda::pseudo_command(int cmd, int data_count)
{
switch (cmd) {

View File

@ -133,6 +133,7 @@ private:
//void cuda_response_packet();
void error_response(uint32_t error);
void process_packet();
void process_adb_command(uint8_t cmd_byte, int data_count);
void pseudo_command(int cmd, int data_count);
/* I2C related methods */