Serial terminal stuurt geen data

Pagina: 1
Acties:

Vraag


Acties:
  • 0 Henk 'm!

  • deepbass909
  • Registratie: April 2001
  • Laatst online: 16-05 18:34

deepbass909

[☼☼] [:::][:::] [☼☼]

Topicstarter
Voor mijn domotica heb ik een RFLink interface. Dit is een Arduino Mega met dochterbord die via de USB aangesloten zit op een linux-machine. De USB communiceert via een serieel protocol en op de linux-machine zie ik ook netjes een serieel device verschijnen (/dev/ttyACM1).

Data die binnenkomt, kan ik via een willekeurig terminal programma of cat ook zichtbaar maken.

Maar, wat ik ook probleem, volgens welke handleiding ook, data versturen wil maar niet lukken.

De seriële instellingen zijn simpel genoeg (57600, 8N1, CR/LF). Minicom heb ik zo ook ingesteld:
code:
1
2
3
4
5
6
7
8
9
10
pu port             /dev/ttyACM1
pu baudrate         57600
pu bits             8
pu parity           N
pu stopbits         1
pu rtscts           No
pu localecho        Yes
pu addlinefeed      Yes
pu linewrap         Yes
pu addcarreturn     Yes


De hardware (RFLink) functioneert ook naar behoren. Aangesloten op een windows machine kan ik met een speciale windows applicatie voor de RFLink namelijk wél data naar de RFLink sturen.

De instructies zijn op zich duidelijk genoeg:
Linux:
Connect RFlink to your Linux system
Run a terminal program like minicom or any software with similar functionality
Connect to the USB port with the following settings: 57600 baud, 8 data bits, 1 stop bit, no parity
Make sure CR/LF (carriage return/line feed) is appended when you send commands
Send the following command: 10;rfdebug=on;
You should see a response that looks like this: 20;03;RFDEBUG=ON; with which RFlink confirms the debug mode
maar de reactie ontvang ik dus niet. Maar wanneer ik met een afstandsbediening een knop indruk, zie ik in de terminal wel data verschijnen.

Wat kan hier de oorzaak van zijn?

Waarschuwing, opperprutser aan het werk... en als je een opmerking van mij niet snapt, klik dan hier

Alle reacties


Acties:
  • 0 Henk 'm!

  • jnr24
  • Registratie: Oktober 2004
  • Laatst online: 16:39
Heb je schrijfrechten op de file? Ik pak even mijn kanon:

chmod 777 /dev/ttyACM1

Acties:
  • +1 Henk 'm!

  • deepbass909
  • Registratie: April 2001
  • Laatst online: 16-05 18:34

deepbass909

[☼☼] [:::][:::] [☼☼]

Topicstarter
jnr24 schreef op zondag 21 juli 2024 @ 01:22:
Heb je schrijfrechten op de file? Ik pak even mijn kanon:

chmod 777 /dev/ttyACM1
Uiteraard heb ik schrijfrechten, de gewone gebruiker waarmee ik test is toegevoegd aan de groep dailout, maar ook met root-rechten werkt het niet.
root@OdroidM1:~# ls -la /dev/ttyACM*
crw-rw---- 1 root dialout 166, 0 Jul 21 00:31 /dev/ttyACM0
crw-rw---- 1 root dialout 166, 1 Jul 21 13:03 /dev/ttyACM1
Uitvoer (execute) rechten zijn niet van toepassing op seriële apparaten, dus 777 is behoorlijk overkill. Maar voor de volledigheid - en tegen beter weten in - heb ik ook getest, met helaas hetzelfde resultaat.

Ik heb het op 2 verschillende linux-machines getest (ARM64 server, waar hij aan moet komen te hangen) als m'n laptop, en op beiden werkt het niet.

Waarschuwing, opperprutser aan het werk... en als je een opmerking van mij niet snapt, klik dan hier


Acties:
  • +1 Henk 'm!

  • Schnupperpuppe
  • Registratie: Maart 2008
  • Laatst online: 13:34
deepbass909 schreef op zondag 21 juli 2024 @ 00:39:
[...]
Make sure CR/LF (carriage return/line feed) is appended when you send commands
[...]
Heb je dit gedaan?

Acties:
  • 0 Henk 'm!

  • deepbass909
  • Registratie: April 2001
  • Laatst online: 16-05 18:34

deepbass909

[☼☼] [:::][:::] [☼☼]

Topicstarter
Check mijn startpost nog eens met de instellingen van minicom ;)

spoiler:
Dus het antwoord is ja

Waarschuwing, opperprutser aan het werk... en als je een opmerking van mij niet snapt, klik dan hier


Acties:
  • 0 Henk 'm!

  • Schnupperpuppe
  • Registratie: Maart 2008
  • Laatst online: 13:34
deepbass909 schreef op zondag 21 juli 2024 @ 17:03:
[...]


Check mijn startpost nog eens met de instellingen van minicom ;)

spoiler:
Dus het antwoord is ja
Ah yes, ik zie het nu.

Acties:
  • 0 Henk 'm!

  • aawe mwan
  • Registratie: December 2002
  • Laatst online: 21:05

aawe mwan

Wat ook leuk is:

deepbass909 schreef op zondag 21 juli 2024 @ 17:03:
[...]
Check mijn startpost nog eens met de instellingen van minicom ;)
Welke instelling bedoel je dan precies? Volgens de handleiding van minicom gaan addlinefeed en addcarreturn namelijk alleen over de data die je ontvangt.

„Ik kan ook ICT, want heel moeilijk is dit niet”


Acties:
  • 0 Henk 'm!

  • deHakkelaar
  • Registratie: Februari 2015
  • Laatst online: 27-07-2024
Grappig, we hadden het net over serial devices in het Raspi draadje:
deHakkelaar in "Raspberry Pi: Ervaringen en Discussie - deel 2"

Ik vermoed ook net als @aawe mwan dat er dan instellingen verkeerd staan.
Had je ook al een andere terminal client geprobeerd zoals bv screen?
$ man screen
[..]
NAME
       screen - screen manager with VT100/ANSI terminal emulation
[..]
       •  If a tty (character special device) name (e.g. "/dev/ttya") is spec‐
          ified as the first parameter, then the window is directly  connected
          to  this  device.   This  window  type  is  similar to "screen cu -l
          /dev/ttya".  Read and write access is required on the  device  node,
          an  exclusive  open  is attempted on the node to mark the connection
          line as busy.  An optional parameter  is  allowed  consisting  of  a
          comma separated list of flags in the notation used by stty(1):

          <baud_rate>
                 Usually  300,  1200, 9600 or 19200. This affects transmission
                 as well as receive speed.

          cs8 or cs7
                 Specify the transmission of eight (or seven) bits per byte.

          ixon or -ixon
                 Enables (or disables) software  flow-control  (CTRL-S/CTRL-Q)
                 for sending data.

          ixoff or -ixoff
                 Enables  (or  disables)  software  flow-control for receiving
                 data.

          istrip or -istrip
                 Clear (or keep) the eight bit in each received byte.

          You may want to specify as many of these options as applicable.  Un‐
          specified options cause the terminal driver to make up the parameter
          values of the connection.  These values are system dependent and may
          be in defaults or values saved from a previous connection.

          For  tty  windows,  the info command shows some of the modem control
          lines in the status line. These may  include  `RTS',  `CTS',  'DTR',
          `DSR',  `CD'  and more.  This depends on the available ioctl()'s and
          system header files as well as the on the physical  capabilities  of
          the  serial  board.   Signals  that  are logical low (inactive) have
          their name preceded by an exclamation mark (!), otherwise the signal
          is logical high (active).  Signals not supported by the hardware but
          available to the ioctl() interface are usually shown low.

          When the CLOCAL status bit is true, the whole set of  modem  signals
          is  placed inside curly braces ({ and }).  When the CRTSCTS or TIOC‐
          SOFTCAR bit is set, the signals `CTS' or `CD' are shown in parenthe‐
          sis, respectively.

          For tty windows, the command break causes the Data transmission line
          (TxD) to go low for a specified period of time. This is expected  to
          be  interpreted  as break signal on the other side.  No data is sent
          and no modem control line is changed when a break is issued.
Bv voor m'n USB GPS muis met default 4800 baud en vergelijkbare instellingen als die van jouw:
$ sudo screen /dev/ttyUSB0 4800,cs8,-parenb,-cstopb,-crtscts,-echo,icrnl,onlcr
[..]
$GPGGA,214357.173,0000.0000,N,00000.0000,E,0,00,50.0,0.0,M,0.0,M,0.0,0000*75
$GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05
$GPGSV,3,1,12,15,89,000,27,30,68,000,,28,62,000,00,23,60,000,29*77
$GPGSV,3,2,12,09,57,000,00,32,48,000,00,20,37,000,,27,35,000,00*78
$GPGSV,3,3,12,26,33,000,,25,29,000,,18,10,000,,12,05,000,*7C
$GPRMC,214357.173,V,0000.0000,N,00000.0000,E,0.00,,051204,,*0B
$GPVTG,,T,,M,,N,,K*4E
$GPGGA,214358.173,0000.0000,N,00000.0000,E,0,00,50.0,0.0,M,0.0,M,0.0,0000*7A

Die parameters komen hier vandaan:
$ man stty
[..]
NAME
       stty - change and print terminal line settings
[..]
   Special settings:
       N      set the input and output speeds to N bauds
[..]
       csN    set character size to N bits, N in [5..8]
[..]
       [-]parenb
              generate parity bit in output and expect parity bit in input
[..]
       [-]cstopb
              use two stop bits per character (one with '-')
[..]
       * [-]crtscts
              enable RTS/CTS handshaking
[..]
       [-]echo
              echo input characters
[..]
       [-]icrnl
              translate carriage return to newline
[..]
       * [-]onlcr
              translate newline to carriage return-newline

En er staan nog veel meer parameter opties in die man page die je kunt meegeven/tweaken.

Je kunt met onder alle huidige parameters weergeven voor je TTY device:
$ sudo stty -a -F /dev/ttyUSB0
speed 4800 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

Ook als minicom of screen deze TTY heeft overgenomen kun je dan zien wat is ingesteld.

EDIT: Ow die screen sessie kun je killen met de toetscombinatie: CTRL-a k
OW2: stty zit in de APT package:
$ dpkg -S /bin/stty
coreutils: /bin/stty

There are only 10 types of people in the world: those who understand binary, and those who don't


Acties:
  • 0 Henk 'm!

  • deHakkelaar
  • Registratie: Februari 2015
  • Laatst online: 27-07-2024
Ik zag een foutje in m'n relaas.
Kom ik nog op terug.

EDIT: Ik krijg het niet voor elkaar om twee parameters tegelijk op te geven voor screen.
Onder werkt en geeft de verwachte output:
code:
1
sudo screen /dev/ttyUSB0 4800

Onder geeft gibberish op het scherm zoals verwacht met 7 ipv 8 bits in een byte:
code:
1
sudo screen /dev/ttyUSB0 cs7

Maar ik kan voor geen mogelijkheid twee parameters meegeven zoals onder voorbeeld en zoals in de documentatie/man page staat omschreven:
code:
1
sudo screen /dev/ttyUSB0 4800,cs7

Alleen de eerste parameter/flag boven 4800 wordt aangepast als ik met stty controleer en de cs7 parameter niet.

Geen idee ofdat dit een bug is of dat ik iets gruwelijks verkeerd doe maar het wordt wel zo uitgelegd ook op het linkje onder wat ik zo ff snel kon vinden:
screen /dev/ttySX baud_rate,cs8
https://www.cyberciti.biz...bsd-screen-set-baud-rate/

Ah wel misschien heb jij meer geluk met screen.
En je hebt in ieder geval nog een tool erbij (stty) om ea te diagnotiseren of handmatig te wijzigen ;)

EDIT: Ow een handmatig voorbeeldje is bv:
$ sudo stty -F /dev/ttyUSB0 4800 cs8 -parenb -cstopb -crtscts -echo icrnl onlcr
$

$ sudo stty -a -F /dev/ttyUSB0
speed 4800 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 100; time = 2;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc

[ Voor 248% gewijzigd door deHakkelaar op 23-07-2024 00:08 ]

There are only 10 types of people in the world: those who understand binary, and those who don't

Pagina: 1