pikasTech / PikaPython

An ultra-lightweight Python interpreter that runs with only 4KB of RAM, zero dependencies. It is ready to use out of the box without any configuration required and easy to extend with C. Similar project: MicroPython, JerryScript.
http://pikapython.com/
MIT License
1.45k stars 132 forks source link

c调用python里的函数,python函数里的return值压力测试下会出错 #333

Closed Returncosmos closed 8 months ago

Returncosmos commented 9 months ago

c调用python里的函数,python函数里的return值压力测试下会出错

c部分代码 obj_run(pikaMain, "mfr_cmd = pack_cmd()"); uint8_t *buf = obj_getBytes(pikaMain, "mfr_cmd");

python部分代码 def pack_cmd(): if key_id == 'MattressMotorCtrl': if m == "0" and n == "corotation": return bytes([0x99,0x01,0x00,0x00,0x00,0x00,0x9a,0xbb]) if m == "0" and n == "reversal": return bytes([0x99,0x02,0x00,0x00,0x00,0x00,0x9b,0xbb]) if m == "1" and n == "corotation": return bytes([0x99,0x03,0x00,0x00,0x00,0x00,0x9c,0xbb]) if m == "1" and n == "reversal": return bytes([0x99,0x04,0x00,0x00,0x00,0x00,0x9d,0xbb]) if m == "2" and n == "corotation": return bytes([0x99,0x05,0x00,0x00,0x00,0x00,0x9e,0xbb]) if m == "2" and n == "reversal": return bytes([0x99,0x06,0x00,0x00,0x00,0x00,0x9f,0xbb]) .......

python的if分支越多,或return个数越多,越容易出现

requestment.txt内容 pikascript-core==v1.12.5 PikaStdLib==v1.12.5 PikaStdDevice==v2.4.0 pika_cjson==v1.2.5 ESP32==v0.4.2 pika_libc==v1.0.2 time==v0.1.9

pikasTech commented 8 months ago

在群里跟进过测试方式了,应该是串口传输的误码问题