Re: [GLLUG] Reading USB serial port broken

2019-09-20 Thread Dimitrios Siganos via GLLUG
In that case, your problem is likely to be with the DSR pin handling.
Experiment with dsrdtr flow control and with toggling the dsr pin manually.


On Fri, 20 Sep 2019 at 14:40, Henrik Morsing via GLLUG <
gllug@mailman.lug.org.uk> wrote:

> On Fri, Sep 20, 2019 at 01:23:44PM +0100, Adrian McMenamin via GLLUG wrote:
> >Did permissions change on your script or on the python exec on an update?
> >Sorry, just a guess but if an ordinary user can see what's crossing the
> >port but your code can't that would seem like something to check.
>
> Hi,
>
> Munin runs as root:
>
> root  1386  0.0  0.0  24212  3560 ?Ss   Aug31   1:26
> /usr/bin/perl -wT /usr/sbin/munin-node
>
> Device is set as per recommendation:
>
> root@albert:/dev# ls -l ttyACM0
> crw-rw 1 root dialout 166, 0 Sep 20 14:32 ttyACM0
>
> Python script as follows:
>
> root@albert:/dev# ls -l /etc/munin/plugins/mvhr_temp
> lrwxrwxrwx 1 root root 41 Dec 23  2018 /etc/munin/plugins/mvhr_temp ->
> /usr/local/munin/lib/plugins/mvhr_temp.py
> root@albert:/dev# ls -l /usr/local/munin/lib/plugins/mvhr_temp.py
> -rwxr-xr-x 1 root staff 1085 Sep 20 11:51
> /usr/local/munin/lib/plugins/mvhr_temp.py
>
> And python:
>
> root@albert:/dev# ls -l $(which python2.7)
> -rwxr-xr-x 1 root root 3685224 Apr  6 02:42 /usr/bin/python2.7
>
> I run tail as root, haven't tried anything else. And the python/munin
> module can open the device, it just gets no output unless tail reads it as
> well.
>
> TBH, Arduinos reboot when something opens the port, and that is how my
> Arduino code works.
>
> I think the problem is not so much that python/munin can't read the output
> but that the Arduino doesn't output anything because it no longer gets the
> signal to reset when python opens it.
>
> Thanks
>
>
> --
> GLLUG mailing list
> GLLUG@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/gllug
-- 
GLLUG mailing list
GLLUG@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/gllug

Re: [GLLUG] Reading USB serial port broken

2019-09-20 Thread Henrik Morsing via GLLUG

On Fri, Sep 20, 2019 at 01:23:44PM +0100, Adrian McMenamin via GLLUG wrote:

Did permissions change on your script or on the python exec on an update?
Sorry, just a guess but if an ordinary user can see what's crossing the
port but your code can't that would seem like something to check.


Hi,

Munin runs as root:

root  1386  0.0  0.0  24212  3560 ?Ss   Aug31   1:26 /usr/bin/perl 
-wT /usr/sbin/munin-node

Device is set as per recommendation:

root@albert:/dev# ls -l ttyACM0
crw-rw 1 root dialout 166, 0 Sep 20 14:32 ttyACM0

Python script as follows:

root@albert:/dev# ls -l /etc/munin/plugins/mvhr_temp
lrwxrwxrwx 1 root root 41 Dec 23  2018 /etc/munin/plugins/mvhr_temp -> 
/usr/local/munin/lib/plugins/mvhr_temp.py
root@albert:/dev# ls -l /usr/local/munin/lib/plugins/mvhr_temp.py
-rwxr-xr-x 1 root staff 1085 Sep 20 11:51 
/usr/local/munin/lib/plugins/mvhr_temp.py

And python:

root@albert:/dev# ls -l $(which python2.7)
-rwxr-xr-x 1 root root 3685224 Apr  6 02:42 /usr/bin/python2.7

I run tail as root, haven't tried anything else. And the python/munin module 
can open the device, it just gets no output unless tail reads it as well.

TBH, Arduinos reboot when something opens the port, and that is how my Arduino code works. 


I think the problem is not so much that python/munin can't read the output but 
that the Arduino doesn't output anything because it no longer gets the signal 
to reset when python opens it.

Thanks


--
GLLUG mailing list
GLLUG@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/gllug

Re: [GLLUG] Reading USB serial port broken

2019-09-20 Thread Henrik Morsing via GLLUG

On Fri, Sep 20, 2019 at 01:40:17PM +0100, Dimitrios Siganos wrote:

That can be answered by:
strace tail -f ...



Doesn't seem to give anything helpful, just open and read.

Thanks

--
GLLUG mailing list
GLLUG@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/gllug

Re: [GLLUG] Reading USB serial port broken

2019-09-20 Thread Dimitrios Siganos via GLLUG
That can be answered by:
strace tail -f ...

On Fri, 20 Sep 2019 at 13:15, Henrik Morsing via GLLUG <
gllug@mailman.lug.org.uk> wrote:

> On Fri, Sep 20, 2019 at 11:00:53AM +0100, Dimitrios Siganos wrote:
> >How do you open the serial port from python?
> >If you use pyserial, try both with hardware flow control on and off like
> >this.
> >
> >ser = serial.Serial(device, baudrate, rtscts=1)
> >and...
> >ser = serial.Serial(device, baudrate, rtscts=0)
> >
>
> Thanks, I just tried both those rtscts settings and neither helped.
>
> I'm just wondering what tail does that makes it work.
>
> Henrik
>
> --
> GLLUG mailing list
> GLLUG@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/gllug
-- 
GLLUG mailing list
GLLUG@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/gllug

Re: [GLLUG] Reading USB serial port broken

2019-09-20 Thread Adrian McMenamin via GLLUG
Did permissions change on your script or on the python exec on an update?
Sorry, just a guess but if an ordinary user can see what's crossing the
port but your code can't that would seem like something to check.
-- 
GLLUG mailing list
GLLUG@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/gllug

Re: [GLLUG] Reading USB serial port broken

2019-09-20 Thread Henrik Morsing via GLLUG

On Fri, Sep 20, 2019 at 11:00:53AM +0100, Dimitrios Siganos wrote:

How do you open the serial port from python?
If you use pyserial, try both with hardware flow control on and off like
this.

ser = serial.Serial(device, baudrate, rtscts=1)
and...
ser = serial.Serial(device, baudrate, rtscts=0)



Thanks, I just tried both those rtscts settings and neither helped.

I'm just wondering what tail does that makes it work.

Henrik  

--
GLLUG mailing list
GLLUG@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/gllug

Re: [GLLUG] Reading USB serial port broken

2019-09-20 Thread Dimitrios Siganos via GLLUG
How do you open the serial port from python?
If you use pyserial, try both with hardware flow control on and off like
this.

ser = serial.Serial(device, baudrate, rtscts=1)
and...
ser = serial.Serial(device, baudrate, rtscts=0)

On Fri, 20 Sep 2019 at 10:31, Henrik Morsing via GLLUG <
gllug@mailman.lug.org.uk> wrote:

> On Fri, Sep 20, 2019 at 10:04:23AM +0100, Dimitrios Siganos wrote:
> >Have you checked that it is not a baud rate, flow control or other serial
> >setting issue? You can strace tail to see what it does.
> >
>
> Hi,
>
> I have checked what my limited skills allow me to, but running a tail on
> the device wouldn't really change those settings.
>
> I have tried setting this:
>
> stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost
> -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh
> -ixon -crtscts
>
> that I found here:
>
> https://playground.arduino.cc/Interfacing/LinuxTTY/
>
> It's like the Python module connecting to the device doesn't set it high
> or whatever it is it normally does when connecting.
>
> Thanks
>
> --
> GLLUG mailing list
> GLLUG@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/gllug
-- 
GLLUG mailing list
GLLUG@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/gllug

Re: [GLLUG] Reading USB serial port broken

2019-09-20 Thread Dimitrios Siganos via GLLUG
Have you checked that it is not a baud rate, flow control or other serial
setting issue? You can strace tail to see what it does.

On Fri, 20 Sep 2019, 08:02 Henrik Morsing via GLLUG, <
gllug@mailman.lug.org.uk> wrote:

>
> Hi,
>
> I have an Arduino connected via USB to a PC, to read sensors around my
> house. It calls a Python script as a Munin plugin.
>
> For quite some time now, and I think this possible broke after an upgrade,
> the Python script gets no output from ttyACM0.
>
> Unless I run a 'tail -f' on the device from the command line! Then it
> works. Otherwise the script just times out getting nothing.
>
> I'm guessing it's down to a kernel change in how it opens or signals
> through USB serial devices but what? Googling for a year has found nothing
> similar to this problem. I'm not really an expert on serial devices and
> even less on USB serial devices.
>
> It's getting really frustrating now as the monitoring just never works
> anymore, so any help appreciated.
>
> Thanks
> Henrik
>
> --
> GLLUG mailing list
> GLLUG@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/gllug
-- 
GLLUG mailing list
GLLUG@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/gllug