Improved printable implementation; data reading with macro

This commit is contained in:
dario
2024-06-26 17:41:56 +02:00
committed by dario
parent b9ccb2d65f
commit ebb14896b8
7 changed files with 56 additions and 16 deletions

View File

@@ -193,4 +193,19 @@ namespace sta
print(buffer, digits, newline);
}
void Printable::read(char * str, size_t length)
{
read(reinterpret_cast<uint8_t*>(str), length * sizeof(char));
}
void Printable::read(float * buffer, size_t length)
{
read(reinterpret_cast<uint8_t*>(buffer), length * sizeof(float));
}
void Printable::read(double * buffer, size_t length)
{
read(reinterpret_cast<uint8_t*>(buffer), length * sizeof(double));
}
} // namespace sta

View File

@@ -20,7 +20,7 @@ namespace sta
printf("\r\n");
}
void PrintablePrintf::read(char * str, size_t length)
void PrintablePrintf::read(uint8_t * str, size_t length)
{
STA_ASSERT(str != nullptr);
STA_ASSERT(length > 0);

View File

@@ -27,10 +27,10 @@ namespace sta
intf_->release();
}
void PrintableUART::read(char * str, size_t length)
void PrintableUART::read(uint8_t * buffer, size_t length)
{
intf_->acquire();
intf_->receive(reinterpret_cast<uint8_t *>(str), length);
intf_->receive(buffer, length);
intf_->release();
}