79093009

Date: 2024-10-16 08:04:30
Score: 0.5
Natty:
Report link

Actually, My read serial code just do two things, which is read data to buffer, and tell the another thread that it is time to process data. Here is my code, hope can help you if you encounter the same problem.

function readSensorData(app, src, ~)
        numBytes = src.NumBytesAvailable;
        % tic
        if numBytes > 0
            newData =  read(src, numBytes, 'uint8');
            app.rawData = [app.rawData; newData'];
            send(app.dataQueue,1)
        end
    end

Which app.rawData has Initialized in setup, and code send(app.dataQueue,1) is tell another thread processing data.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: ysl