johnlauer/serial-port-json-server

If opening a port fails, subsequent attempts to open any other port fail as well

Opened this issue · 1 comments

From console of Simple WebsocketClient

open /dev/ttyUSB433 115200
open /dev/ttyUSB433 115200
{"Cmd":"OpenFail","Desc":"Error opening port. open /dev/ttyUSB433: no such file or directory","Port":"/dev/ttyUSB433","Baud":115200}
open /dev/ttyUSB433 115200
open /dev/ttyUSB433 115200
open /dev/ttyUSB433 115200
open /dev/ttyUSB433 115200
open /dev/ttyUSB0 115200
open /dev/ttyUSB0 115200

From logs

2017/04/21 15:54:06 hub.go:122: open /dev/ttyUSB433 115200
2017/04/21 15:54:06 serialport.go:373: Inside spHandler
2017/04/21 15:54:06 serialport.go:389: Opening serial port /dev/ttyUSB433 at 115200 baud
2017/04/21 15:54:06 serialport.go:434: Just tried to open port
2017/04/21 15:54:06 serialport.go:437: Error opening port open /dev/ttyUSB433: no such file or directory
2017/04/21 15:54:08 hub.go:122: open /dev/ttyUSB433 115200
2017/04/21 15:54:08 serialport.go:373: Inside spHandler
2017/04/21 15:54:08 serialport.go:376: We are currently in the middle of opening a port. Returning...
2017/04/21 15:54:09 hub.go:122: open /dev/ttyUSB433 115200
2017/04/21 15:54:09 serialport.go:373: Inside spHandler
2017/04/21 15:54:09 serialport.go:376: We are currently in the middle of opening a port. Returning...
2017/04/21 15:54:34 hub.go:122: open /dev/ttyUSB0 115200
2017/04/21 15:54:34 serialport.go:373: Inside spHandler
2017/04/21 15:54:34 serialport.go:376: We are currently in the middle of opening a port. Returning...

It appears spHandler doesn't properly handle the exception, thinking its still trying to open the port that aborted.

Opened pull request #60

Don't see any tests for this app. So I guess this will hopefully be good...