Recent

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

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #165 on: September 30, 2016, 12:09:59 am »
hello,
jb007, are you using event or sequential serial port read ?
Can you put your lazarus source code in a zip file in attachment to have a look to your code ?

Friendly, J.P
« Last Edit: September 30, 2016, 12:14:16 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #166 on: October 01, 2016, 08:17:50 pm »
Hi,

gonna to that monday-evening.

Regards.

to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #167 on: October 05, 2016, 10:17:15 pm »
Some more patience please....

Did some modifications.

More to come...



to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #168 on: October 06, 2016, 08:56:27 pm »
Things're getting better.

See the picture added.

All string received perfect, no errors.

From time to time I delete the field of incoming strings, by clicking in the field ( memobox).
Just to be sure, I don't know much text it can contain.

In the code I've modified some thing but another major thing is that I now use the onboard RS232 port.
I had some strange acting with the extern-USB-hub with the USB-to-serial-pcbs. Dont's knowe exactly
where the problem is, but from time to the the pc messaged hardware connected/disconnected You know when you're in decive manager and thing begin to pop when connecting/disconnecting hardware. In my case that was COM 4 ( via the USB-hub...usb_to_serial etc etc )

Going to find out what the problem is, later.

Soon I'll strip my code to RS232 comucication only: remove the slide bars etc etc..to get short and clear code
and will post it here in zipp. as asked.

As next i gonna remove the texwritng in the left box, it's been tested, so don't need to see it...

send/receive each 250ms:








to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #169 on: October 06, 2016, 09:01:18 pm »
AAajjj...there it is... a hang up during debugging in Lazarus.

Mousepointer can get no reaction on whatever on my form.

After a while next message apeared.

At t he time the hang up occured, I was doing more work on my pc than before...

I was posting my previous comment....

Gonna investigate!

to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #170 on: October 06, 2016, 10:48:13 pm »
Started new run, without displaying the incoming string. Only displaying errors.
The 1 error is deu of strat u my Arduino.

Ruuning allready for about 100 minutes...
to DIY or not to DIY

PStechPaul

  • Jr. Member
  • **
  • Posts: 76
    • P S Technology, Inc.
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #171 on: October 06, 2016, 11:42:25 pm »
About the USB serial problems, I found that some USB cables (perhaps most) have unreliable connection of the shell to the shield. The shell is just crimped to the shield over the jacket and eventually the connection becomes unreliable. Measure resistance from one end to the other, while wiggling the cable near the connector. The gold-flashed cables seem to be the best.

Also, some USB-serial adapters do not do well for closely spaced bytes of data, due to timeout issues. My communication device sends two 8 bit + 1 start + 1 stop bit as a packet, 2400 per second, at 57.6 kB. So that is 20 bits x 2400 = 48 kB, and only a short period of time between packets.

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #172 on: October 07, 2016, 02:57:32 pm »
Tnx!

Me too!

Now the pc-to-Arduino-RS232 is going by the pc-on-board-RS232-port.
Programming the Arduino goes via a USB-cable with a virtula-pc-serial-port.
( I had some strange 'reseting'of the Arduino, proberly  caused by a cable...


But things deffinitely have improved. No wrong strings received  :D and just occasianly I had an application-hang-up ( in both in Lazarus-Debug-Mode and in Free-Running )
Needs more investigation....

More info:

Arduino: 115200kbaud/kbps, non-parity, one stopbit.

Lazarus: 115200kbaud/kbps, non-parity, one stopbit.

At this moment, pc-sends 6 bytes, Arduino sends 28 bytes:

( say: 8 bits/byte + 1, we  round it to 10 )
115200 / 28x10 = aprox 411

Time of 1 send-period = 1 /  411 = aprox 2,4ms

SendingReceiving is done 4 times a second ( delta-T = 250ms )

All regards.

I'm very happy I'm this far ow with the whole stuf!

« Last Edit: October 07, 2016, 03:16:35 pm by jb007 »
to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #173 on: October 07, 2016, 03:34:33 pm »
Measured my 4 cables included within the Arduino's...

From end to end the shield/base:

1) 44 Ohm
2) 30 Ohm
3) no Ohm at all...
4) no Ohm at all...



Grr.... >:(



to DIY or not to DIY

tr_escape

  • Sr. Member
  • ****
  • Posts: 432
  • sector name toys | respect to spectre
    • Github:
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #174 on: October 25, 2016, 04:22:20 pm »
Hello,

I have an experience about TLazSerial in that procedure:

Code: Pascal  [Select][+][-]
  1. procedure TLazSerial.DeviceClose;
  2. begin
  3.   // flush device
  4.   if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
  5.     FSynSer.Flush;
  6.     FSynSer.Purge;
  7.   end;
  8.  
  9.   // stop capture thread
  10.   if ReadThread<>nil then begin
  11.     ReadThread.FreeOnTerminate:=false;
  12.     ReadThread.MustDie:= True;
  13.     while not ReadThread.Terminated do begin
  14.       try
  15.         Application.ProcessMessages;
  16.       except
  17.         Break;   // I added this and try except block
  18.       end;
  19.     end;
  20.     ReadThread.Free;
  21.     ReadThread:=nil;
  22.   end;
  23.  
  24.   // close device
  25.   if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
  26.     FSynSer.Flush;
  27.     FSynSer.CloseSocket;
  28.   end;
  29. end;
  30.  

I have got 6 com ports and each port has diffrent configuration like as baud and protocol.
When I attempt to Close all ports sometimes my software locking and I had to close forcibly.

What whould be happen in this line?

I create a break point in that case but I couldn't catch any problem.







Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #175 on: October 26, 2016, 02:02:19 am »
hello,
tr_escape, the deviceClose procedure of TLazserial comes from 5dposerial . The MustDie property of the ReadThread must stop the loop.
Code: Pascal  [Select][+][-]
  1. procedure TComPortReadThread.Execute;
  2. begin
  3.   try
  4.     while not MustDie do begin
  5.       if Owner.FSynSer.CanReadEx(100) then
  6.         Synchronize(@CallEvent);
  7.     end;
  8.   finally
  9.     Terminate;
  10.   end;
  11.  
  12. end;

Where are you when your software is locked ?

Maybe you can try this :
Code: Pascal  [Select][+][-]
  1. procedure TLazSerial.DeviceClose;
  2. begin
  3.   // flush device
  4.   if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
  5.     FSynSer.Flush;
  6.     FSynSer.CloseSocket;
  7.  //   FSynSer.Purge;
  8.   end;            

Close the port before the Mustdie.

Friendly, J.P
« Last Edit: October 26, 2016, 02:36:08 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Mi-Ki

  • Jr. Member
  • **
  • Posts: 74
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #176 on: November 05, 2016, 05:35:13 pm »
Hello.
I have a raspberry - raspbian-jessie and Lazarus 1.2.4
Why not compile LazSerial?

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #177 on: November 05, 2016, 05:44:34 pm »
hello,
Mi-ki, What is the error message ? 
tr_escape , have you always your problem ?

Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

tr_escape

  • Sr. Member
  • ****
  • Posts: 432
  • sector name toys | respect to spectre
    • Github:
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #178 on: November 05, 2016, 05:56:59 pm »
hello,
tr_escape , have you always your problem ?

Hello,

My problem is solved there was some hardware issue. ( Usb multiplexer's power problem)
I roll backed my changes.

Thanks a lot.

Mi-Ki

  • Jr. Member
  • **
  • Posts: 74
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #179 on: November 06, 2016, 07:56:00 am »
I unwrapped LazSerial.7z to /home/pi/Downloads/
Package - open package file(.lpk)
Open LazSerialPort.lpk
Compile pakage
Code: Pascal  [Select][+][-]
  1. /home/pi/Downloads/LazSerial/synafpc.pas(80,28) Hint: Parameter "Module" not used
  2. /home/pi/Downloads/LazSerial/synafpc.pas(80,48) Hint: Parameter "Buffer" not used
  3. /home/pi/Downloads/LazSerial/synafpc.pas(80,63) Hint: Parameter "BufLen" not used
  4. /home/pi/Downloads/LazSerial/synautil.pas(609,51) Warning: Symbol "TimeSeparator" is deprecated
  5. /home/pi/Downloads/LazSerial/synautil.pas(679,27) Hint: Local variable "x" does not seem to be initialized
  6. /home/pi/Downloads/LazSerial/synautil.pas(1922,3) Note: Local variable "BackStop" is assigned but never used
  7. /home/pi/Downloads/LazSerial/synautil.pas(2062,43) Warning: Symbol "ShortMonthNames" is deprecated
  8. /home/pi/Downloads/LazSerial/synautil.pas(2063,42) Warning: Symbol "ShortMonthNames" is deprecated
  9. /home/pi/Downloads/LazSerial/synautil.pas(87,22) Hint: Unit "synafpc" not used in synautil
  10. /home/pi/Downloads/LazSerial/synaser.pas(252,22) Error: Identifier not found "B500000"
  11. /home/pi/Downloads/LazSerial/synaser.pas(252,22) Error: Illegal expression
  12. /home/pi/Downloads/LazSerial/synaser.pas(253,21) Error: Identifier not found "B576000"
  13. /home/pi/Downloads/LazSerial/synaser.pas(253,21) Error: Illegal expression
  14. /home/pi/Downloads/LazSerial/synaser.pas(254,21) Error: Identifier not found "B921600"
  15. /home/pi/Downloads/LazSerial/synaser.pas(254,21) Error: Illegal expression
  16. /home/pi/Downloads/LazSerial/synaser.pas(255,23) Error: Identifier not found "B1000000"
  17. /home/pi/Downloads/LazSerial/synaser.pas(255,23) Error: Illegal expression
  18. /home/pi/Downloads/LazSerial/synaser.pas(256,23) Error: Identifier not found "B1152000"
  19. /home/pi/Downloads/LazSerial/synaser.pas(256,23) Error: Illegal expression
  20. /home/pi/Downloads/LazSerial/synaser.pas(257,23) Error: Identifier not found "B1500000"
  21. /home/pi/Downloads/LazSerial/synaser.pas(257,23) Error: Illegal expression
  22. /home/pi/Downloads/LazSerial/synaser.pas(258,23) Error: Identifier not found "B2000000"
  23. /home/pi/Downloads/LazSerial/synaser.pas(258,23) Error: Illegal expression
  24. /home/pi/Downloads/LazSerial/synaser.pas(259,23) Error: Identifier not found "B2500000"
  25. /home/pi/Downloads/LazSerial/synaser.pas(259,23) Error: Illegal expression
  26. /home/pi/Downloads/LazSerial/synaser.pas(260,23) Error: Identifier not found "B3000000"
  27. /home/pi/Downloads/LazSerial/synaser.pas(260,23) Error: Illegal expression
  28. /home/pi/Downloads/LazSerial/synaser.pas(261,23) Error: Identifier not found "B3500000"
  29. /home/pi/Downloads/LazSerial/synaser.pas(261,23) Error: Illegal expression
  30. /home/pi/Downloads/LazSerial/synaser.pas(262,23) Error: Identifier not found "B4000000"
  31. /home/pi/Downloads/LazSerial/synaser.pas(262,23) Error: Illegal expression
  32. /home/pi/Downloads/LazSerial/synaser.pas(765,1) Fatal: There were 22 errors compiling module, stopping
  33.  
In Windows it works

 

TinyPortal © 2005-2018