techninja / cncserver

A RESTful API server for driving serial based CNC devices
133 stars 40 forks source link

Immediate serial port disconnect on Windows #93

Open jbjw opened 6 years ago

jbjw commented 6 years ago

I'm having issues running cncserver on my Windows machine - it successfully connects to my Axidraw and then immediately disconnects, giving this error: RUNNER:undefinedError: Reading from COM port (ReadIOCompletion): Operation aborted (full output at the bottom), and then continues in simulation mode.

After a bit of research, it looks like it may be an issue with calling flush on a serial port that's listening. Here's someone else having the same issue: https://github.com/node-serialport/node-serialport/issues/1409, so seems it's a serialport bug on Windows. I tried downgrading serialport from v6 to v4, but it looks like cncserver relies on v6.

I'm wondering if it's possible to, as a workaround, skip the flush for whichever serial commands happen while the port is still listening. I'll try my hand at implementing that, but I'm pretty new to both this project and serialport (and serial protocol 😛).

Here's my full output when running node cncserver.js:

Successfully loaded config for AxiDraw! Initializing...
Starting IPC server, waiting for runner client to start...
== CNCServer Debug mode is ON ==
RUNNER:Connected to CNCServer!
Finding available serial ports...
RUNNER:Config data:{"debug":true,"ack":"OK","showSerial":true}
Full Available Port Data: [ { comName: 'COM5',
    manufacturer: 'SchmalzHaus LLC',
    serialNumber: '5&2E5451CF&0&5',
    pnpId: 'USB\\VID_04D8&PID_FD92\\5&2E5451CF&0&5',
    locationId: 'Port_#0005.Hub_#0001',
    vendorId: '04D8',
    productId: 'FD92' } ]
Using first detected port: "COM5"...
Attempting to open serial port: "COM5"...
RUNNER:Connect to:{"port":"COM5","baudRate":9600}
Serial connection open at 9600bps
CONNECTSERIAL CONNECT!
CNC server API listening on *:4242
Sending EBB config...
---=== AxiDraw is ready to receive commands ===---
RUNNER:CONNECTED TO  COM5
RUNNER:RUNNING ITEM: fa592b93b8a65d26
RUNNER:Executing serial write: EM,2
RUNNER:SerialSendtoDrain: 3.388ms
RUNNER:ITEM DONE: fa592b93b8a65d26
RUNNER:RUNNING ITEM: 8fc02c0ec00d6015
RUNNER:Executing serial write: SC,10,65535
RUNNER:undefinedError: Reading from COM port (ReadIOCompletion): Operation abort
ed
Serialport connection to "COM5" lost!! Did it get unplugged?
=======Continuing in SIMULATION MODE!!!============
RUNNER ERROR: WRITE TIMEOUT, COMMAND FAILED: SC,10,65535
bdilloughery commented 6 years ago

I am having the exact same error. Installed everything on a 64 bit Windows 10. Changed the config.ini for bot type top be the axidraw.

Everything works when I run robopaint in the background, so the connection is good. I was just trying to use the CNC Server to manually control the layout of the pen controls, but ran into the exact error above.

Help please =)


Additionally, I opened a web browser and though it says above that the connection was essentially lost, my http protocol is still communicating with the axidraw - it just isn't doing anything.

localhost:4242/poll returns the correct states of the axidraw localhost:4242/pen.down gives an HTTP status code of 200 but nothing happens