#qi-hardware IRC log for Thursday, 2014-10-09

--- Thu Oct 9 201400:00
DocScrutinizer05hey, maybe somebody here can help me out. Trying to control a PSU (PPS-11xxx Voltcraft  http://www.reinhardweiss.de/german/sonstiges.htm) via shell, and everything finally works with "echo -e GMOD\r >/dev/ttyUSB0". But I can't for the life of mine find the right stty setting to set up the tty so it does convert <ENTER> into a "\r" (e.g. a "cat >/dev/ttyUSB0" simply doesn't work, no matter what I do via stty). Am I suffering some 14:13
DocScrutinizer05misconception there regarding what stty can do and that it maybe doesn't work at all for cat>somwehere, or is there a trick how to use the stty parameters?14:13
DocScrutinizer05in short: what do I need to do so the "\r" in "echo -e GMOD\r >/dev/ttyUSB0" is not needed anymore?14:15
rohDocScrutinizer05: forget stty and similar pita. (serials termios suck).. take pyserial and hack up a python script15:04
rohalso some drivers forget the settings on serial close, so you cannot properly set stuff on shellscripts15:04
DocScrutinizer05well, you can, opening tty on evak on fdN15:05
DocScrutinizer05eval 4<ttyUSB15:05
DocScrutinizer05been there, done that. but it seems stty and/or ioctl of tty doesn't work like supposed to15:07
DocScrutinizer05I wrote a stepper motor controller a while back, and I ran into exactly same problem back when. Seems tty doesn't obey what man 1 stty suggests onlcr etc are supposed to accomplish15:09
DocScrutinizer05talk2controller(){echo -en "$@\r"}15:11
DocScrutinizer05which is kinda insane15:11
DocScrutinizer05tty driver SHOULD handle this15:11
DocScrutinizer05I wasted 4 hours trying to talk to that sucker PSU via minicom15:13
DocScrutinizer05no luck, probably just because I wasn't able to terminate COMMAND by \r15:14
DocScrutinizer05there must be a bug in tty driver since 200715:15
DocScrutinizer05at least15:15
DocScrutinizer05but hey, you might be right, I tried to set ourput properties before output channel (fd) been opened15:18
DocScrutinizer05nope :-/15:22
DocScrutinizer05I seem to recall some settings in /dev/tty* were sticky and stty didn't take effect on second time. But I forgot what to do to reset the tty, except the obvious powercycling15:23
DocScrutinizer05sounds like http://stackoverflow.com/questions/7812142/how-to-toggle-cr-lf-in-gnu-screen >>In the past, onlcr didn't work on USB to serial adapters using the pl2303 driver. That bug has been fixed, but some devices use old Linux kernels.   dreamlayers Nov 1 '11 at 2:26<<15:28
DocScrutinizer05or like this: http://stackoverflow.com/questions/10068886/expect-script-not-sending-new-line-correctly15:36
wpwraki'm speechless :)17:33
kyakevery kid's dream :(17:35
wpwrakDocScrutinizer05: (serial) roh has a good point there - you often need more control over the comm channel with this sort of devices than you may expect. it's VERY common to run into subtle communication problems.17:49
DocScrutinizer05ok, now I know *I* have a problem (=bug), not stty.17:49
wpwrakheh, good timing, eh ? :-)17:49
DocScrutinizer05echo -e 'GETD\r' >/dev/ttyUSB017:49
DocScrutinizer05echo -e 'GETD' | tr \n \r >/dev/ttyUSB017:49
wpwrakand yes, what i meant is bugs :) e.g., my fluke sometimes fails to answer. then you have to restart the connection. but that sometimes fails too, but only after the next operation.17:50
wpwrakthe rigol DS1xxxCD has a whole catalog of such issues, apparently caused by lack of internal flow control. `C, ~D, and ~E probably, too. (same platform)17:51
wpwrakthese are the two i use(d) the most. so i know their bugs best. i think the picotest DMM (usbtmc) also has some quirks17:53
DocScrutinizer05well, whatever17:54
wpwraknaw, you really want to know exactly which bytes are going over the line and when. with shell scripts you're at a far too high level.17:54
DocScrutinizer05I'm not able to grok what's going on with \r on my shell17:54
wpwrake.g., you'll probably also run into timing constraints. things like having to wait for the unit to process a command before it can accept the next (without overrunning buffers). etc.17:55
DocScrutinizer05echo -e 'GETDx\n' | tr x \r >/dev/ttyUSB0    fails17:55
wpwrakyou can see with strace what  really happens underneath17:56
DocScrutinizer05is \r a delimiter that gets handled even in pipes?17:56
wpwrakbut it's easier just to write these things in C17:56
DocScrutinizer05or what?17:56
wpwrakif you want a library that gives you access to such stuff, you could look here: https://gitorious.org/lab-tools/tmc17:58
DocScrutinizer05meh, escaping17:58
wpwraklow-level comms in C, the rest in python. there's also lib/power.py with very simple power supply control17:58
DocScrutinizer05saturn:~ # echo -e 'GETDx\n' | tr x \r | od -xa17:58
DocScrutinizer050000000    4547    4454    0a72    000a17:58
DocScrutinizer05          G   E   T   D   r  nl  nl17:58
DocScrutinizer05saturn:~ # echo -e 'GETDx\n' | tr x \\r | od -xa17:59
DocScrutinizer050000000    4547    4454    0a0d    000a17:59
DocScrutinizer05          G   E   T   D  cr  nl  nl17:59
DocScrutinizer05\o/ I'm not completely braindamaged18:01
DocScrutinizer05saturn:~ # echo -e 'GETD\n\n' | tr \\n \\r >/dev/ttyUSB018:01
DocScrutinizer05saturn:~ # 04020000018:01
DocScrutinizer05saturn:~ # echo 'GETD' | tr \\n \\r >/dev/ttyUSB018:02
DocScrutinizer05saturn:~ # 04020000018:02
DocScrutinizer05alas this still doesn't explain why damn stty reduses to do same like tr does, despite 18:04
DocScrutinizer05       * [-]onlcr18:04
DocScrutinizer05              translate newline to carriage return-newline18:04
DocScrutinizer05suggests it should18:04
DocScrutinizer05saturn:~ # stty -a  </dev/ttyUSB0|grep onl18:07
DocScrutinizer05-opost -olcuc -ocrnl onlcr -onocr onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff018:07
DocScrutinizer05((lib/power.py)) sorry what?18:09
DocScrutinizer05I find backup-20090831/usr/share/paroli/services/hardware/power.pyo and /usr/lib/python2.7/site-packages/synaptiks/monitors/power.py18:11
wpwrakin https://gitorious.org/lab-tools/tmc  18:12
DocScrutinizer05Written by Werner Almesberger <werner@openmoko.org>   --  hehe18:13
wpwrakpower.py is a (very simple) class for power supplies. you could add yours there. the infrastructure gives you communications and "active" variables18:13
DocScrutinizer05much appreciated18:13
wpwrakyea, these were the old days :)18:13
wpwrakthe basic idea is that you have a "nice" python interface on top to model your instrument, and C at the bottom to get low-level comms right18:14
wpwrakif you look at telnet.c, you'll see what nightmares may await you down there :)18:15
eintopfeverywhere you will find code written by werner18:16
wpwrakeintopf: maybe i should sue poettering for stealing my trademark ;-)18:19
eintopfwpwrak: you are like "eric s. raymond" for me, I stumble sometimes also much on "eric s. raymond" patches18:23
eintopfand then I am "raymoning" again, something like "rickrocklling"18:24
wpwrakhmm, i guess that's what i deserve from comparing my style with poettering :)18:24
eintopfmaybe we should introduce "almesbergering"18:24
DocScrutinizer05hmmm   >> These libraries are not documented yet, but there is a number of annotated examples in the demo/ directory.<<18:24
eintopfeverytime you stumble over code by you18:24
wpwrakbut i have to admit that i'm a happy and very regular user of fetchmail :)18:25
DocScrutinizer05don't tell me it's written by poettering18:26
wpwrakDocScrutinizer05: yes, i left them out in the "migrated" version (from openmoko). examples are for sissies :)18:26
wpwrak(fetchmail) no, by esr18:26
DocScrutinizer05I dunno if I want to use stuff that I basically have to read top-down every single line, to understand _how_ to use it. Prolly simpler to fix tty.ko and write stuff myself ;-)18:27
roheeeh.. are you flushing the tty buffers?18:43
rohno /n means no automatic buffer flush. when you have so few chars, they are prolly still idling in your fifo :)18:44
rohi urge you. do it in python or C. speaking anything not crlf-auto-default linefeeds in shell is breaking your knees madness18:44
rohalso every > /dev/serialdevice call opens and closes the serial once. some serials 'forget' some details of their config inbetween (bad drivers i guess). so using stty doesnt help18:45
rohopen, config termios (thats what pyserial does for you then, yay!!1!) then your 'traffic' and close when done is what one wants to do.. to avoid weird drivers/hardware18:46
DocScrutinizer05my problem is with \r, NOT with \n18:55
DocScrutinizer05and that's the only problem I have, rather it's an inconventience since nothing on linux is ever sending a \r when EOL18:56
DocScrutinizer05I don't even see how pyserial would help there18:56
DocScrutinizer05still would need the equivalent to talk2controller(){echo -en "$@\r"}18:57
DocScrutinizer05and I told you even shellscript is capable of keeping a file handle open: eval 5>/dev/ttyUSB 6</dev/ttyUSB18:59
DocScrutinizer05my problem is that neither minicom nor screen nor any other approach is capable to allow me talking interactively to device, for testing stuff.19:01
DocScrutinizer05cat|tr \\n \\r>/dev/ttyUSB0; however should do19:02
DocScrutinizer05just it sucks donkeyballs19:02
DocScrutinizer05no, it doesn't. Here buffering kicks in19:04
DocScrutinizer05obviously tr needs EOF on STDIN to print filtered stuff to STDOUT19:07
DocScrutinizer05while read ...19:07
whitequarkDocScrutinizer05: http://www.plunk.org/~grantham/cgi-bin/blog.cgi?id=0001519:09
whitequarkmay or may not help19:10
DocScrutinizer05whitequark: ta19:19
DocScrutinizer05btw prolly smarter than previous version:  while read; do echo $REPLY|tr \\n \\r; done >/dev/ttyUSB0;19:21
DocScrutinizer05still pissed why stty onlcr doesn't work19:23
DocScrutinizer05ok, so much for "improving UI via remote control". The PSU has no switch to conveniently beak output for a short period of time (like 1s or 2). Using power switch is a PITA since it a) takes ages to deplete the primary side buffer caps of SPSU and b) the device runs a full selftest on power-up which again takes 10s or sth19:45
DocScrutinizer05however SOUT1 instantly breaks and SOUT0 instantly enables output19:46
DocScrutinizer05of course a VOLT060 is also more conventient than fiddling with that incremental turn dial19:47
--- Fri Oct 10 201400:00

Generated by irclog2html.py 2.9.2 by Marius Gedminas - find it at mg.pov.lt!