mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
add writeBytes template
This commit is contained in:
parent
46c468bdc3
commit
962a280555
@ -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");
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user