NRF24减轻了Flask的有效载荷

时间:2018-07-03 12:24:20

标签: python python-3.x flask

我正在使用带有NRF24模块的Raspberry和Arduino。我也在使用Flask进行交流。

我的问题是,我在流程循环中丢失了一些消息。如果我运行与自己的脚本相同的代码,则会得到每个msg。您是否知道如何解决此问题?

代码:

while 1:
                            if (radio.available()):
                                size = radio.getDynamicPayloadSize()
                                if (size == 32):
                                    #correct size of the payload
                                    radio.read(receivedMessage, size)
                                    RcvMsg = translate_from_radio(receivedMessage, size)
                                    print (str(RcvMsg))

                                    SndMsg = [1030, RcvMsg[1], int(time.time()),0,0,0,0,0]
                                    SndMsg = translate_to_radio(SndMsg)
                                    radio.writeAckPayload(1, SndMsg, len(SndMsg))

输出烧瓶:

[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 3, 1530199522, 68699, 1665, 11]
[1030, 0, 0, 4, 1530199548, 102128, 2463, 14]
[1030, 0, 0, 5, 1530199586, 85373, 2063, 17]
[1030, 0, 0, 6, 1530199618, 102169, 2464, 20]
[1030, 0, 0, 7, 1530199656, 35157, 861, 23]
[1030, 0, 0, 8, 1530199670, 93541, 2258, 26]
[1030, 0, 0, 9, 1530199705, 54667, 1330, 29]
[1030, 0, 0, 10, 1530199726, 116119, 2797, 32]
[1030, 0, 0, 11, 1530199769, 110465, 2662, 35]
[0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 16, 1530199918, 104855, 2528, 50]
[1030, 0, 0, 17, 1530199957, 101751, 2454, 53]
[1030, 0, 0, 18, 1530199995, 99363, 2397, 56]
[1030, 0, 0, 19, 1530200032, 49011, 1195, 59]
[1030, 0, 0, 20, 1530200051, 127263, 3063, 62]
[1030, 0, 0, 21, 1530200098, 18883, 463, 65]
[0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 24, 1530200162, 80090, 1937, 74]
[1030, 0, 0, 25, 1530200193, 144603, 3477, 77]
[1030, 0, 0, 26, 1530200248, 111718, 2692, 80]
[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 28, 1530200342, 18804, 461, 86]
[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 30, 1530200373, 96304, 2324, 92]
[1030, 0, 0, 31, 1530200409, 157967, 3796, 95]
[1030, 0, 0, 32, 1530200467, 124287, 2992, 98]
[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 34, 1530194131, 27102, 664, 105]
[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 36, 1530194224, 16718, 410, 111]
[1030, 0, 0, 37, 1530261285, 26898, 659, 114]
[0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 40, 1530274907, 9344, 248, 123]
[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 42, 1530274917, 6421, 171, 129]
[0, 0, 0, 0, 0, 0, 0, 0]
[1030, 0, 0, 44, 1530274938, 5973, 159, 135]
[1000, 9402641, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0]
[1000, 9402649, 0, 0, 0, 0, 0, 0]
[1000, 9402651, 0, 0, 0, 0, 0, 0]
[1000, 9402652, 0, 0, 0, 0, 0, 0]

独立输出:

[1030, 0, 0, 1, 1530199372, 0, 0, 5]
[1030, 0, 0, 2, 1530199472, 135685, 3264, 8]
[1030, 0, 0, 3, 1530199522, 68699, 1665, 11]
[1030, 0, 0, 4, 1530199548, 102128, 2463, 14]
[1030, 0, 0, 5, 1530199586, 85373, 2063, 17]
[1030, 0, 0, 6, 1530199618, 102169, 2464, 20]
[1030, 0, 0, 7, 1530199656, 35157, 861, 23]
[1030, 0, 0, 8, 1530199670, 93541, 2258, 26]
[1030, 0, 0, 9, 1530199705, 54667, 1330, 29]
[1030, 0, 0, 10, 1530199726, 116119, 2797, 32]
[1030, 0, 0, 11, 1530199769, 110465, 2662, 35]
[1030, 0, 0, 12, 1530199810, 18883, 463, 38]
[1030, 0, 0, 13, 1530199818, 137985, 3319, 41]
[1030, 0, 0, 14, 1530199869, 74271, 1798, 44]
[1030, 0, 0, 15, 1530199897, 51903, 1264, 47]
[1030, 0, 0, 16, 1530199918, 104855, 2528, 50]
[1030, 0, 0, 17, 1530199957, 101751, 2454, 53]
[1030, 0, 0, 18, 1530199995, 99363, 2397, 56]
[1030, 0, 0, 19, 1530200032, 49011, 1195, 59]
[1030, 0, 0, 20, 1530200051, 127263, 3063, 62]
[1030, 0, 0, 21, 1530200098, 18883, 463, 65]
[1030, 0, 0, 22, 1530200106, 32582, 798, 68]
[1030, 0, 0, 23, 1530200119, 115951, 2793, 71]
[1030, 0, 0, 24, 1530200162, 80090, 1937, 74]
[1030, 0, 0, 25, 1530200193, 144603, 3477, 77]
[1030, 0, 0, 26, 1530200248, 111718, 2692, 80]
[1030, 0, 0, 27, 1530200290, 141128, 3394, 83]
[1030, 0, 0, 28, 1530200342, 18804, 461, 86]
[1030, 0, 0, 29, 1530200350, 60070, 1459, 89]
[1030, 0, 0, 30, 1530200373, 96304, 2324, 92]
[1030, 0, 0, 31, 1530200409, 157967, 3796, 95]
[1030, 0, 0, 32, 1530200467, 124287, 2992, 98]
[1030, 0, 0, 33, 1530200513, 76953, 1862, 101]
[1030, 0, 0, 34, 1530194131, 27102, 664, 105]
[1030, 0, 0, 35, 1530194216, 489, 11, 108]
[1030, 0, 0, 36, 1530194224, 16718, 410, 111]
[1030, 0, 0, 37, 1530261285, 26898, 659, 114]
[1030, 0, 0, 38, 1530261076, 9557, 235, 117]
[1030, 0, 0, 39, 1530261095, 9111, 224, 120]
[1030, 0, 0, 40, 1530274907, 9344, 248, 123]
[1030, 0, 0, 41, 1530274914, 1410, 37, 126]
[1030, 0, 0, 42, 1530274917, 6421, 171, 129]
[1030, 0, 0, 43, 1530274923, 12302, 326, 132]
[1030, 0, 0, 44, 1530274938, 5973, 159, 135]

在Flask中,我像这样启动函数:

if __name__ == '__main__':
        g_com_clip = Array('i', 5)

        p = Process(target=com_clip, args=())
        p.start()
        app.run(host='0.0.0.0', port=5001, debug=True)  

0 个答案:

没有答案