Recent

Author Topic: TLazSerial : serial port component for Lazarus (windows and linux).  (Read 344993 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #375 on: September 29, 2021, 07:56:24 pm »
I've been looking in my notes but can find my fix quickly. 
The issue is not with pascal, it with the OS.  The OS removes LF chars from the comm port streams, even binary.  what you need to do is to tell the OS to not filter the stream.  you can probably find the commands faster than I on the web...

First thing to try is stty sane. However there's a specific funny in one of the serial device drivers which I've seen causing problems with faux-Arduino boards...

Code: C  [Select][+][-]
  1. /* This is the first project for which I've used Eclipse to program Arduinos
  2.  * with a CH340 chip. As of Eclipse 4.13 expect "staircasing" on those ports,
  3.  * see http://e2e.ti.com/support/tools/ccs/f/81/t/716472?CCS-EVMK2H-Serial-terminal-in-CCS-8-1-0-under-Linux-is-not-displaying-newlines-correctly
  4.  * for a fix but in short use a command like
  5.  *
  6.  * stty -F /dev/ttyUSBn -icrnl
  7.  *
  8.  * to disable kernel-level conversion of incoming carriage return (\r) to
  9.  * newline (\n) which will cause staircasing and double-spacing.
  10.  */
  11.  

Posted in the hope that it might be a useful addition to general knowledge, but without promising that it#s a fix in the current case.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

LaurentDelaon

  • New Member
  • *
  • Posts: 20
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #376 on: September 29, 2021, 09:13:48 pm »
I never speak of an Arduino.
And I ever said that I have a correct reception with no load charge cpu of the terminal program.

The problem is a bad interrupt of the RXread procedure as it  didnt appears... 

thank's.
lazarus 2.2.0
lazarus 2.2.0
fpc 3.2.2
linux x86 gtk2 ubuntu 18.04.6LTS

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #377 on: September 29, 2021, 09:20:13 pm »
I didn't say- or certainly didn't intend to imply- that it was Arduino-specific. It's a bug in one of the Linux serial driver modules which can be worked-around using stty... and I'd point out that you didn't give any details of the hardware you were using so I thought it worth throwing in lest it be relevant >:-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

LaurentDelaon

  • New Member
  • *
  • Posts: 20
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #378 on: September 29, 2021, 10:26:07 pm »
yes, thank's for your help.
lazarus 2.2.0
lazarus 2.2.0
fpc 3.2.2
linux x86 gtk2 ubuntu 18.04.6LTS

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #379 on: September 30, 2021, 01:41:50 am »
hello
I have a pb with SerialRxData;

to illustrate:
msg1 raw:
dst 0 6C02 ldt 88.50 5120
msg1:
dem dst?:dst 0 6C02 <-crc 1rst msg dst
ldt 88.50 5120>7E81<NOKcrc

           crc ldt|       |here add after receive and recalcul crc...
dst is a distance measure.
ldt is lidar temperature.
as you can see lazserial miss a #10 char separator
it's happen when  I do video flux with sdpovideo.

msg2:
dem gps?:gps 0 0 0 0 0 0 0 0 0902
ypr 288.8 -12.3 -5.7 6EC8>1999<NOKcrc


msg gps is follow by ypr mesg. Lose #10 separator. So the two message are not separated...
your examples are not very clear -> can you show  all the hexa bytes which are sent  ( ex 00 FF AA 13 10 ...) and what is received in SerialRxData and the code in the SerialRxData.
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

alpine

  • Hero Member
  • *****
  • Posts: 1062
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #380 on: September 30, 2021, 11:31:05 am »
As I said

with no video treatment  this is perfecly working.

with video (charge cpu and threads) it's happens some mistake
message wich are separated before  sending with a chr(10) are not correctly parse/treated...

so this is not the OS.

Just a wild guess... You're using OnRxData event for receiving, which is called internally through TThread.Synchronized() and when the CPU is loaded it fails to execute your handler on time.
That way some bytes gets lost. Losing the #10 may be is just a coincidence. No way that initialized tty can translate cr/lf differently with respect of the CPU load.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

LaurentDelaon

  • New Member
  • *
  • Posts: 20
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #381 on: September 30, 2021, 11:47:28 am »
Hi

I'am pretty agree with your analisys y.ivanov!

No way to LF.
But the strange is that alll mesages are  only not serate and generally absolutly complete...


So I thinks that's a pb  of interrupt code as you explain :
is the soltuion to protect this thread part critical ?


thank's
« Last Edit: September 30, 2021, 12:04:18 pm by LaurentDelaon »
lazarus 2.2.0
lazarus 2.2.0
fpc 3.2.2
linux x86 gtk2 ubuntu 18.04.6LTS

LaurentDelaon

  • New Member
  • *
  • Posts: 20
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #382 on: September 30, 2021, 11:57:46 am »
with no problem:
ypr 258.7 12.8 -6.9 1446 //entete+3 reels+crc16
--------------ok
dst 329 F3D8 //entete+1 reel+crc16
--------------ok
ldt 85.10 A462 //entete+1 reel+crc16
--------------ok
gps 0 0 0 0 0 0 0 0 0902 //entete+8 integer+crc16
--------------ok


with problem (msg seem uncorretly receive ):
structure_message_example_nok:
"dem ?:"+bad_message+">"+crc16_receive_msg+"<NOKcrc"

dem ?:ldt 82.40 0ABA
gps 0 0 0 ypr 258.6 12.8 -7.1 7A37>0354<NOKcrc
+++++ nok
dem ?:ypr 258.6 12.ldt 86.10 3FBE>FCE2<NOKcrc
+++++ nok
dem ?:lps 0 0 0 0 0 0 0 0 0902>EB3C<NOKcrc  //ici melange ldt and gps
+++++ nok
ypr 258.7 12.8 -7.1 A27E
--------------ok
dem ?:ypr 258.7 12.ldt 90.30 D414>6C29<NOKcrc // message ypr dernier reel manque fract
+++++ nok

Not hexa but seem indicate a  pb of interruption rx thread as says y.ivanov...

« Last Edit: September 30, 2021, 12:08:42 pm by LaurentDelaon »
lazarus 2.2.0
lazarus 2.2.0
fpc 3.2.2
linux x86 gtk2 ubuntu 18.04.6LTS

alpine

  • Hero Member
  • *****
  • Posts: 1062
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #383 on: September 30, 2021, 12:37:51 pm »
@LaurentDelaon,
Are we discussing actually the https://github.com/JurassicPork/TLazSerial/tree/master/test program?
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

LaurentDelaon

  • New Member
  • *
  • Posts: 20
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #384 on: September 30, 2021, 12:48:37 pm »
No discuss about this with him and me...
But maybe is it a very good idea....


I suggest modify his test prog like this :

add on form test a  sdpo video and observe if the messages gps are perturbates.
This is hardware dependent, but if we reproduce problem it's ok.

I can modify it's prog but I haven't gps.
I try to do it and inform you after realise this.

Then I will give the modified code if JurrassikPork is agree to help me  , on a real code problem it's better.

Laurent.
 
 

 

lazarus 2.2.0
lazarus 2.2.0
fpc 3.2.2
linux x86 gtk2 ubuntu 18.04.6LTS

LaurentDelaon

  • New Member
  • *
  • Posts: 20
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #385 on: September 30, 2021, 04:59:27 pm »
Hi JurassikPork

I have modified your program test. 8)
I have include a video via a camera ; you can select video source and possibly modify zoom factor to increase load cpu (says 10 fps is like my condition  system).
to use it you should compile it with  sdpovideo and bgrabitmappack.
The setting initial parameter will not work after the video is on. (so set your serial before...)

Could you please try your communication with your gps observe whats happen with video on and cpu load at 10 fps ?

(You may check crc todetect badmessages.)

thanks for your help.  :)
Laurent.
 
« Last Edit: October 01, 2021, 06:27:10 pm by LaurentDelaon »
lazarus 2.2.0
lazarus 2.2.0
fpc 3.2.2
linux x86 gtk2 ubuntu 18.04.6LTS

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #386 on: October 01, 2021, 09:23:36 am »
hello,
sdpovideo must be a cpu muncher . Try to use another video display component.
Example :  TPasLibVlcPLayer
i have try this component in my sertest project ---> no problem to receive gps frames while displaying ip camera
(see attachment).
The code of the button video on is :
Code: Pascal  [Select][+][-]
  1. PasLibVlcPlayer1.Play(WideString('http://webcam-roggwil1.bioforce.ch/axis-cgi/mjpg/video.cgi'));  
Friendly,J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

LaurentDelaon

  • New Member
  • *
  • Posts: 20
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #387 on: October 01, 2021, 12:26:04 pm »
thank's for your reply.
How did you do to read: /dev/video0 ?

Laurent.
« Last Edit: October 01, 2021, 12:39:56 pm by LaurentDelaon »
lazarus 2.2.0
lazarus 2.2.0
fpc 3.2.2
linux x86 gtk2 ubuntu 18.04.6LTS

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #388 on: October 01, 2021, 12:58:17 pm »
thank's for your reply.
How did you do to read: /dev/video0 ?
on windows i can see the first webcam with this command :
Code: Pascal  [Select][+][-]
  1. PasLibVlcPlayer1.Play(WideString('dshow://'));
dshow only on windows (directshow). On linux it is another command (may be tv://) , see the vlc documentation.
Ami calmant, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

LaurentDelaon

  • New Member
  • *
  • Posts: 20
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #389 on: October 01, 2021, 04:36:20 pm »
the answwer is:

Code: Pascal  [Select][+][-]
  1. PasLibVlcPlayer1.Play(WideString('v4l2:///dev/video0'));
« Last Edit: October 01, 2021, 06:26:37 pm by LaurentDelaon »
lazarus 2.2.0
lazarus 2.2.0
fpc 3.2.2
linux x86 gtk2 ubuntu 18.04.6LTS

 

TinyPortal © 2005-2018