python-lacrosse icon indicating copy to clipboard operation
python-lacrosse copied to clipboard

Serial connection only over relay (socat)

Open PickManInTheMiddle opened this issue 7 years ago • 2 comments

A JeeLink is connected to /dev/ttyUSB0.

Everything described below is executed with a user has full access to /dev/ttyUSB0:

When I try to scan the sensors using the following command, there is no response from pylacrosse: pylacrosse -r 1 -d /dev/ttyUSB0 scan

To monitor the behavior, I created a relay with socat: socat /dev/ttyUSB0,raw,echo=0 SYSTEM:'tee in.txt |socat - "PTY,link=/tmp/ttyUSB0,raw,echo=0,waitslave" |tee out.txt'

Started pylacrosse again using the relay:

pylacrosse -r 1  -d /tmp/ttyUSB0 scan
id=16 t=-0.100000 h=85 nbat=0 name=unknown
id=32 t=0.700000 h=83 nbat=0 name=unknown

Strangely now pylacrosse is displaying my sensors...

Terminal programs (tested with picoterm and here with pythons minicom) are also working:

python -m serial.tools.miniterm /dev/ttyUSB0 57600
--- Miniterm on /dev/ttyUSB0  57600,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
␀

[LaCrosseITPlusReader.10.1s (RFM69CW f:868300 r:17241)]
1r
v

[LaCrosseITPlusReader.10.1s (RFM69CW f:868300 r:9579)]
OK 9 43 1 4 116 53
OK 9 16 1 3 231 85

--- exit ---

Info:The commands "1r" and "v" were not echoed and added manually.

The info-command also works with pylacrosse (for /dev/ttyUSB0 and /tmp/ttyUSB0):

pylacrosse -d /dev/ttyUSB0 info
name:     LaCrosseITPlusReader
version:  10.1s
rfm1name: RFM69CW
rfm1frequency: 868300
rfm1datarate: 17241
rfm1toggleinterval: None
rfm1togglemask: None

Used versions:

  • pylacrosse: 0.3.1 (as shown in version.py)
  • python: 3.7.1

PickManInTheMiddle avatar Dec 16 '18 15:12 PickManInTheMiddle

This is really strange. I added my "standard" users to the plugdev group (ttyUSB is automatically added by to this by debian) to have access to the device.

hthiery avatar Dec 18 '18 10:12 hthiery

Yes, stange indeed.

I was also able to reproduce the problem on a windows host.

My "solution" for this problem was, that I compliled the JeeLink firmware with a default datarate of 9579.

LaCrosseITPlusReader10.ino (line 47): unsigned long DATA_RATE_R1 = 9579ul;

Now, pylacrosse starts with the right datarate and no commands are needed.

I seems that not command reaches the JeeLink.

PickManInTheMiddle avatar Dec 24 '18 11:12 PickManInTheMiddle