2021-10-01 20:00:15 +08:00
|
|
|
#include "PikaStdDevice_UART.h"
|
|
|
|
#include "BaseObj.h"
|
|
|
|
|
|
|
|
void PikaStdDevice_UART_enable(PikaObj* self) {
|
2022-03-19 09:53:48 +08:00
|
|
|
obj_runNativeMethod(self, "platformEnable", NULL);
|
2021-10-01 20:00:15 +08:00
|
|
|
}
|
2022-03-07 14:58:21 +08:00
|
|
|
|
|
|
|
void PikaStdDevice_UART_disable(PikaObj *self){
|
2022-03-19 09:53:48 +08:00
|
|
|
obj_runNativeMethod(self, "platformDisable", NULL);
|
2022-03-07 14:58:21 +08:00
|
|
|
}
|
|
|
|
|
2021-10-01 20:00:15 +08:00
|
|
|
void PikaStdDevice_UART_init(PikaObj* self) {
|
|
|
|
obj_setInt(self, "baudRate", 115200);
|
|
|
|
obj_setInt(self, "id", 1);
|
|
|
|
obj_setStr(self, "readBuff", "");
|
|
|
|
}
|
2021-12-10 23:02:40 +08:00
|
|
|
|
|
|
|
void PikaStdDevice_UART___init__(PikaObj* self) {
|
|
|
|
PikaStdDevice_UART_init(self);
|
|
|
|
}
|
|
|
|
|
2021-10-01 20:00:15 +08:00
|
|
|
char* PikaStdDevice_UART_read(PikaObj* self, int length) {
|
|
|
|
obj_setInt(self, "length", length);
|
2022-03-19 09:53:48 +08:00
|
|
|
obj_runNativeMethod(self, "platformRead", NULL);
|
2021-10-01 20:00:15 +08:00
|
|
|
return obj_getStr(self, "readData");
|
|
|
|
}
|
2022-05-23 17:10:37 +08:00
|
|
|
|
|
|
|
Arg* PikaStdDevice_UART_readBytes(PikaObj *self, int length){
|
|
|
|
obj_setInt(self, "length", length);
|
|
|
|
obj_runNativeMethod(self, "platformReadBytes", NULL);
|
2022-05-24 15:26:12 +08:00
|
|
|
return arg_copy(obj_getArg(self, "readData"));
|
2022-05-23 17:10:37 +08:00
|
|
|
}
|
|
|
|
|
2021-10-01 20:00:15 +08:00
|
|
|
void PikaStdDevice_UART_setBaudRate(PikaObj* self, int baudRate) {
|
|
|
|
obj_setInt(self, "baudRate", baudRate);
|
|
|
|
}
|
|
|
|
void PikaStdDevice_UART_setId(PikaObj* self, int id) {
|
|
|
|
obj_setInt(self, "id", id);
|
|
|
|
}
|
|
|
|
void PikaStdDevice_UART_write(PikaObj* self, char* data) {
|
|
|
|
obj_setStr(self, "writeData", data);
|
2022-03-19 09:53:48 +08:00
|
|
|
obj_runNativeMethod(self, "platformWrite", NULL);
|
2021-10-01 20:00:15 +08:00
|
|
|
}
|
|
|
|
|
2022-05-23 17:10:37 +08:00
|
|
|
void PikaStdDevice_UART_writeBytes(PikaObj *self, uint8_t* data, int length){
|
|
|
|
obj_setBytes(self, "writeData", data, length);
|
|
|
|
obj_runNativeMethod(self, "platformWriteBytes", NULL);
|
|
|
|
}
|
|
|
|
|
2021-11-14 19:40:06 +08:00
|
|
|
void PikaStdDevice_UART_platformEnable(PikaObj* self) {
|
2022-08-26 19:41:25 +08:00
|
|
|
ABSTRACT_METHOD_NEED_OVERRIDE_ERROR();
|
2021-10-01 20:00:15 +08:00
|
|
|
}
|
2021-11-14 19:40:06 +08:00
|
|
|
void PikaStdDevice_UART_platformRead(PikaObj* self) {
|
2022-08-26 19:41:25 +08:00
|
|
|
ABSTRACT_METHOD_NEED_OVERRIDE_ERROR();
|
2021-10-01 20:00:15 +08:00
|
|
|
}
|
2021-11-14 19:40:06 +08:00
|
|
|
void PikaStdDevice_UART_platformWrite(PikaObj* self) {
|
2022-08-26 19:41:25 +08:00
|
|
|
ABSTRACT_METHOD_NEED_OVERRIDE_ERROR();
|
2021-11-14 19:44:15 +08:00
|
|
|
}
|
2022-03-19 09:49:19 +08:00
|
|
|
|
|
|
|
void PikaStdDevice_UART_platformDisable(PikaObj *self){
|
2022-08-26 19:41:25 +08:00
|
|
|
ABSTRACT_METHOD_NEED_OVERRIDE_ERROR();
|
2022-03-19 09:49:19 +08:00
|
|
|
}
|
|
|
|
|
2022-05-23 17:10:37 +08:00
|
|
|
void PikaStdDevice_UART_platformReadBytes(PikaObj *self){
|
2022-08-26 19:41:25 +08:00
|
|
|
ABSTRACT_METHOD_NEED_OVERRIDE_ERROR();
|
2022-05-23 17:10:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PikaStdDevice_UART_platformWriteBytes(PikaObj *self){
|
2022-08-26 19:41:25 +08:00
|
|
|
ABSTRACT_METHOD_NEED_OVERRIDE_ERROR();
|
2022-05-23 17:10:37 +08:00
|
|
|
}
|