add writeBytes template

This commit is contained in:
lyon 2022-05-24 20:58:58 +08:00
parent 46c468bdc3
commit 962a280555
3 changed files with 22 additions and 2 deletions

View File

@ -1,4 +1,5 @@
#include "TemplateDevice_UART.h"
#include <stdio.h>
void TemplateDevice_UART_platformDisable(PikaObj* self) {}
void TemplateDevice_UART_platformEnable(PikaObj* self) {}
@ -10,4 +11,12 @@ void TemplateDevice_UART_platformReadBytes(PikaObj* self) {
obj_setBytes(self, "readData", bytes_buff, length);
}
void TemplateDevice_UART_platformWrite(PikaObj* self) {}
void TemplateDevice_UART_platformWriteBytes(PikaObj* self) {}
void TemplateDevice_UART_platformWriteBytes(PikaObj* self) {
uint8_t* bytes = obj_getBytes(self, "writeData");
int length = obj_getBytesSize(self, "writeData");
printf("[debug]: write to uart: [ ");
for (int i = 0; i < length; i++) {
printf("0x%02X ", bytes[i]);
}
printf("]\n");
}

View File

@ -22,3 +22,5 @@ def test():
uart.setBaudRate(115200)
bt = uart.readBytes(5)
EXPECT_EQ('uart.readBytes', bt, b'\x00\x01\x02\x03\x04')
uart.writeBytes(b'\xff\xfe\xfd\xfc', 4)

View File

@ -1,4 +1,5 @@
#include "TemplateDevice_UART.h"
#include <stdio.h>
void TemplateDevice_UART_platformDisable(PikaObj* self) {}
void TemplateDevice_UART_platformEnable(PikaObj* self) {}
@ -10,4 +11,12 @@ void TemplateDevice_UART_platformReadBytes(PikaObj* self) {
obj_setBytes(self, "readData", bytes_buff, length);
}
void TemplateDevice_UART_platformWrite(PikaObj* self) {}
void TemplateDevice_UART_platformWriteBytes(PikaObj* self) {}
void TemplateDevice_UART_platformWriteBytes(PikaObj* self) {
uint8_t* bytes = obj_getBytes(self, "writeData");
int length = obj_getBytesSize(self, "writeData");
printf("[debug]: write to uart: [ ");
for (int i = 0; i < length; i++) {
printf("0x%02X ", bytes[i]);
}
printf("]\n");
}