Serial data missing bits #174

Closed
greengiant83 opened this Issue Jun 13, 2013 · 3 comments

Comments

Projects
None yet
4 participants

Love this plugin, voodootikigod, thanks for putting it together.

I am having problems reading complete lines from a usb serial port on a raspberry pi.

The device is writing out text like this:

line:97,posx:-130.314,posy:-200.000,posz:-200.000,posa:0.000,feed:0.000,vel:8750.131,unit:1,coor:1,dist:0,frmo:0,momo:0,stat:4
line:97,posx:-145.640,posy:-200.000,posz:-200.000,posa:0.000,feed:0.000,vel:9521.280,unit:1,coor:1,dist:0,frmo:0,momo:0,stat:4
line:97,posx:-161.406,posy:-200.000,posz:-200.000,posa:0.000,feed:0.000,vel:9328.487,unit:1,coor:1,dist:0,frmo:0,momo:0,stat:4
line:97,posx:-176.013,posy:-200.000,posz:-200.000,posa:0.000,feed:0.000,vel:8171.766,unit:1,coor:1,dist:0,frmo:0,momo:0,stat:4

These lines are delimited by a new line character ("\n")

Unfortunately what I read from my node server the feed is missing some data. For instance here is an example of the data I get back

 line:101,posx:-213.318,posy:-200.000,posz:-200.coor:1,dist:0,frmo:0,momo:0,stat:4line:101,posx:-218.095,posy:-200.000,posz:-200..577,unit:1,coor:1,dist:0,frmo:0,moline:101,posx:-219.789,posy:-200.000,posz:-200.coor:1,dist:0,frmo:0,momo:0,stat:4line:101,posx:-220.000,posy:-200.000,posz:-200or:1,dist:0,frmo:0,momo:0,stat:3

if I manually insert line breaks I get this:

 line:101,posx:-213.318,posy:-200.000,posz:-200.coor:1,dist:0,frmo:0,momo:0,stat:4
 line:101,posx:-218.095,posy:-200.000,posz:-200..577,unit:1,coor:1,dist:0,frmo:0,mo
 line:101,posx:-219.789,posy:-200.000,posz:-200.coor:1,dist:0,frmo:0,momo:0,stat:4
 line:101,posx:-220.000,posy:-200.000,posz:-200or:1,dist:0,frmo:0,momo:0,stat:3

which makes it look like it starts dropping data after about 80-85 characters into a line.

If I bring up the same port in screen on the command line I can see the complete lines. In windows the maker of the device suggested that i turn on XON flow control. I don't know if that actually has anything to do with this or not.

Here is my code

var serialport = require("serialport");
var SerialPort = serialport.SerialPort;
var usbPort;

console.log("Opening serial port...");
usbPort = new SerialPort("/dev/ttyUSB0", { baudrate: 115200, parser: serialport.parsers.readline("\n") });

//USB Serial Port Opened
usbPort.on("open", function ()
{
    console.log("USB Serial Port Opened");

    sendUSBMessage("x-100\nx-200\n");

    //USB Serial Port Data Received
    usbPort.on("data", function (data)
    {
        console.log(data);
    });
});


function sendUSBMessage(message)
{
    console.log("Sending USB Message: " + message);
    usbPort.write(message, function (err, results)
    {
        console.log("err " + err);
        console.log("results " + results);
    });
}

Collaborator

voodootikigod commented Aug 13, 2013

Awesome data, will try to identify. Thanks for the kind words, but its more than just me (increasingly more so of late), but will spread the love around!

Let me try to mock this up and see if I can fix it.

Collaborator

JayBeavers commented Nov 12, 2013

@greengiant83 , I think issue #203 is dealing with your issue and I'd like to close this one as a duplicate. Do you concur?

Collaborator

reconbot commented Apr 2, 2014

I'm going to close due to age, but feel free to reopen if this is still an issue.

@reconbot reconbot closed this Apr 2, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment