Skip to content

Commit

Permalink
[coco][fuji] base64_encode_output()
Browse files Browse the repository at this point in the history
  • Loading branch information
tschak909 committed May 1, 2024
1 parent 1a4ba19 commit 69aaf3c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/device/drivewire/fuji.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,28 @@ void drivewireFuji::base64_encode_length()
errorCode = 1;
}

void drivewireFuji::base64_encode_output()
{
uint8_t lenl = fnUartBUS.read();
uint8_t lenh = fnUartBUS.read();
uint16_t len = lenl << 8 | lenl;

if (!len)
{
Debug_printf("Refusing to send zero byte buffer. Exiting.");
errorCode = 144;
return;
}

std::vector<unsigned char> p(len);
std::memcpy(p.data(), base64.base64_buffer.data(), len);
base64.base64_buffer.erase(0, len);
base64.base64_buffer.shrink_to_fit();

response = std::string((const char *)p.data(), len);
errorCode = 1;
}

// Initializes base settings and adds our devices to the DRIVEWIRE bus
void drivewireFuji::setup(systemBus *drivewirebus)
{
Expand Down Expand Up @@ -1517,6 +1539,7 @@ void drivewireFuji::process()
base64_encode_length();
break;
case FUJICMD_BASE64_ENCODE_OUTPUT:
base64_encode_output();
break;
case FUJICMD_BASE64_DECODE_INPUT:
break;
Expand Down
1 change: 1 addition & 0 deletions lib/device/drivewire/fuji.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class drivewireFuji : public virtualDevice
void base64_encode_input(); // 0xD0
void base64_encode_compute(); // 0xCF
void base64_encode_length(); // 0xCE
void base64_encode_output(); // 0xCD
void send_error();
void send_response(); // 0x01
void ready(); // 0x00
Expand Down

0 comments on commit 69aaf3c

Please sign in to comment.