mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
add print_rcv to test Mem arg
This commit is contained in:
parent
034fb16ea1
commit
7362ba0d4b
@ -1,7 +1,7 @@
|
||||
#include "ctypes_Test.h"
|
||||
#include "ctypes_c_float.h"
|
||||
#include "ctypes_c_uint.h"
|
||||
#include "ctypes_c_wchar_p.h"
|
||||
#include "ctypes_c_float.h"
|
||||
#include "ctypes_utils.h"
|
||||
|
||||
void ctypes_c_uint___init__(PikaObj* self, int value) {
|
||||
@ -12,7 +12,7 @@ void ctypes_c_wchar_p___init__(PikaObj* self, char* value) {
|
||||
ctypesUtils_setStr(self, value);
|
||||
}
|
||||
|
||||
void ctypes_c_float___init__(PikaObj *self, float value){
|
||||
void ctypes_c_float___init__(PikaObj* self, float value) {
|
||||
ctypesUtils_setFloat(self, value);
|
||||
}
|
||||
|
||||
@ -27,6 +27,18 @@ int ctypes_Test_dc_cpuapdu_hex(PikaObj* self,
|
||||
int slen) {
|
||||
printf("input: slen = %d, sendbuf = %s\n", slen, sendbuf);
|
||||
ctypesUtils_setInt(rlen, 5);
|
||||
ctypesUtils_setStr(rcvbuf, "testout");
|
||||
char rcv[] = {0x01, 0x02, 0x03, 0x00, 0x05, 0x08};
|
||||
ctypesUtils_setMem(rcvbuf, rcv, sizeof(rcv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ctypes_Test_print_rcv(PikaObj* self, PikaObj* rcvbuf) {
|
||||
char* rcv = ctypesUtils_getMem(rcvbuf);
|
||||
size_t rcv_size = ctypesUtils_getMemSize(rcvbuf);
|
||||
__platform_printf("{");
|
||||
for (size_t i = 0; i < rcv_size - 1; i++) {
|
||||
__platform_printf("%x, ", rcv[i]);
|
||||
}
|
||||
__platform_printf("%x", rcv[rcv_size - 1]);
|
||||
__platform_printf("}\r\n");
|
||||
}
|
||||
|
@ -32,3 +32,4 @@ class c_longdouble(c_float):...
|
||||
class Test(TinyObj):
|
||||
def add(self, c_uint1:c_uint, c_uint2:c_uint)->int:...
|
||||
def dc_cpuapdu_hex(self, slen:int, sendbuf:str, rlen:c_uint, rcvbuf:c_char_p) -> int:...
|
||||
def print_rcv(self, rcvbuf: c_char_p):...
|
||||
|
@ -32,3 +32,4 @@ class c_longdouble(c_float):...
|
||||
class Test(TinyObj):
|
||||
def add(self, c_uint1:c_uint, c_uint2:c_uint)->int:...
|
||||
def dc_cpuapdu_hex(self, slen:int, sendbuf:str, rlen:c_uint, rcvbuf:c_char_p) -> int:...
|
||||
def print_rcv(self, rcvbuf: c_char_p):...
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "ctypes_Test.h"
|
||||
#include "ctypes_c_float.h"
|
||||
#include "ctypes_c_uint.h"
|
||||
#include "ctypes_c_wchar_p.h"
|
||||
#include "ctypes_c_float.h"
|
||||
#include "ctypes_utils.h"
|
||||
|
||||
void ctypes_c_uint___init__(PikaObj* self, int value) {
|
||||
@ -12,7 +12,7 @@ void ctypes_c_wchar_p___init__(PikaObj* self, char* value) {
|
||||
ctypesUtils_setStr(self, value);
|
||||
}
|
||||
|
||||
void ctypes_c_float___init__(PikaObj *self, float value){
|
||||
void ctypes_c_float___init__(PikaObj* self, float value) {
|
||||
ctypesUtils_setFloat(self, value);
|
||||
}
|
||||
|
||||
@ -27,6 +27,18 @@ int ctypes_Test_dc_cpuapdu_hex(PikaObj* self,
|
||||
int slen) {
|
||||
printf("input: slen = %d, sendbuf = %s\n", slen, sendbuf);
|
||||
ctypesUtils_setInt(rlen, 5);
|
||||
ctypesUtils_setStr(rcvbuf, "testout");
|
||||
char rcv[] = {0x01, 0x02, 0x03, 0x00, 0x05, 0x08};
|
||||
ctypesUtils_setMem(rcvbuf, rcv, sizeof(rcv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ctypes_Test_print_rcv(PikaObj* self, PikaObj* rcvbuf) {
|
||||
char* rcv = ctypesUtils_getMem(rcvbuf);
|
||||
size_t rcv_size = ctypesUtils_getMemSize(rcvbuf);
|
||||
__platform_printf("{");
|
||||
for (size_t i = 0; i < rcv_size - 1; i++) {
|
||||
__platform_printf("%x, ", rcv[i]);
|
||||
}
|
||||
__platform_printf("%x", rcv[rcv_size - 1]);
|
||||
__platform_printf("}\r\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user