[Python] pyserial to ajax php jquery javascript

Discussão em 'Python' iniciado por Stack, Janeiro 26, 2025.

  1. Stack

    Stack Membro Participativo

    This is a high level question. I have hardware generating serial data every 3 seconds. I use a PySerial script to read the port and write the data to a text file.

    ser = serial.Serial(
    port='COM3',
    baudrate=2400,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.SEVENBITS
    )

    array = [];
    while True:
    message = ser.read();
    fo = open("../wamp/www/amt/test5.txt", "w")
    fo.write(message);
    array = [];
    fo.close()


    This isn't the whole script, but represents what I'm doing. The web application then uses a ajax $.GET call to retrieve the data from the text file. I can then make the data to dance for me. (Data likes to dance)

    $.get('test5.txt', function (data) {

    var a = data.substring(data.indexOf('A')+1,data.indexOf('A')+4);
    var v = data.substring(data.indexOf('V')+1,data.indexOf('V')+4);

    }


    The Problem is that anywhere between 5 hours and 2 days the systems just stops working. No feedback. The only things that fixes it is changing the name of the text file.

    I assume that I am hitting a limit on the read and write of the text file. Another theory is that I am hitting the max on my memory usage and the software fails. What do you think? How do I fix this more permanently?

    Continue reading...

Compartilhe esta Página