Recent

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

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #120 on: July 18, 2016, 10:39:50 am »
Oh...I',m sorry...wasn't aware that this item was more than just 1 page.

Firts I'm gonna read and studdie the complete item, containing the 8 pages...

All regards!


But..if anyone has a clear answer to my previous post, don't hesitate to post it!
« Last Edit: July 18, 2016, 10:51:34 am by jb007 »
to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #121 on: July 19, 2016, 12:38:42 pm »
So far so good!

Based on 'sertest GPS'.
Used the program to sends the pc-time to the Arduino-LCD.

Strange thing is that the Arduino receives 2 extra characters before the actual string.

to DIY or not to DIY

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #122 on: July 19, 2016, 01:38:55 pm »

Strange thing is that the Arduino receives 2 extra characters before the actual string.
Cast it to PAnsiChar first. Then the meta-data for length and refcount will be stripped.
A pascal string has that information at a negative offset hence the two extra bytes.


« Last Edit: July 19, 2016, 01:40:39 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #123 on: July 20, 2016, 02:16:07 pm »
Thanks, Thaddy.

( for the time being, I just removed the 2 first char's at the Arduino/receiver )

Gotta studie moren things. I'm using serial.writedata ()
And there could be more. Like serial.writetext?

Tried to find a overview with all methods/procedures but I dont'get it.
I 'uses' Lazserial and Synaser.

When google I found this, but these are mehods for another Object?
http://synapse.ararat.cz/doc/help/synaser.TBlockSerial.html

Or I'm I making a logic-thinking-failure due of the LazSerial/Synaser I'm using?
Do I mix things up?

All regards.

to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #124 on: July 29, 2016, 06:30:55 pm »
It's improving each time.

First I ixtended the original program "sertest" with some "own" functions:
timer, open, close, send manualy, send automaticly by the timer.

These send the pc-time to the Arduino and it's being displayed ont it's display.

Time after time a removed lot's from the "sertest" till there's only a basic Serial program left over.
( al the gps-stuff, editbox/menu's etc etc have been removed )


Now I got a nice "basis" to work with for my future projects e.g. robotArm etc.

manualy can send an text to my arduino.
the pc-time is send every second (timer).
the scrollbar sends it's value to my arduino and indicatis by a LEDbarGraph.



« Last Edit: July 29, 2016, 06:32:49 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 #125 on: August 08, 2016, 11:52:25 am »
After a break, got some significant progress!

Value of 3 ScrollBars is sended by RS232 to my Arduino.
At 3 LedBars, the values are displayed as (0-255) values.
( gonna be in 0 to 8 led's later as is it showing an audio-level-indicater )

In Lazarus the refresh rate is 10/sec. Only the value of the last changed Scrollbar is sended to Arduino. At my Lazarus INIT al of the 3 wil be sended!




« Last Edit: August 08, 2016, 12:23:54 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 #126 on: August 08, 2016, 12:05:46 pm »
I'm using

1 byte as LedbarNumber and

3 bytes as LedBarValue.

The string 'el' (end-line) is added as delimiter.

to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #127 on: August 08, 2016, 12:21:33 pm »
I'm very happy I got this far programming RS232.

Next step is to controll my robotArm by PC-RS232-Arduino!


Fortunately I got the major part for controlling my robotArm allready
coded in TurbuPascal7.0 and the control is done by ISA/ 82c55a.

The whole ForWard/BackWard-Kinematics, stepperControl and overal mathematics for Interpolation/Integral/Differential for creating a path in 3d.

http://europakade.nl/motion-control-an-robots/robot-arm

https://www.youtube.com/playlist?list=PL7iWs5bvJdxs91kCZUV9P6KuG4mvriLgJ


to DIY or not to DIY

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #128 on: August 10, 2016, 10:34:50 am »
Hi, thank you for the component, which works fine on raspberry, the only flaw is that it must be on a form. Because if I try to use this library. Compiles, but when using it faults.

Code: Pascal  [Select][+][-]
  1. unit Unit_Epson_TM_T70II;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, LazSerial;
  9.  
  10.   type
  11.  
  12.       { TEpson_TM_T70II }
  13.  
  14.       TEpson_TM_T70II = class
  15.  
  16.  
  17.       private
  18.             Seriale: TLazSerial;
  19.             procedure Inizializza();
  20.             procedure LineeBianche(numero: integer);
  21.  
  22.  
  23.       public
  24.             constructor Create(Sender: TComponent; device: string);
  25.             function Stampa():boolean;
  26.             destructor  Free();
  27.  
  28.  
  29.       end;
  30.  
  31.  
  32. implementation
  33.  
  34. { TEpson_TM_T70II }
  35.  
  36. procedure TEpson_TM_T70II.Inizializza;
  37. begin
  38.      Seriale.WriteData(Chr(27) + Chr(64));
  39. end;
  40.  
  41. procedure TEpson_TM_T70II.LineeBianche(numero: integer);
  42. begin
  43.      if numero<0 then
  44.         numero:=0;
  45.      if numero>255 then
  46.         numero:=255;
  47.  
  48.      Seriale.WriteData(chr(27) + chr(100) + chr(numero));
  49. end;
  50.  
  51. constructor TEpson_TM_T70II.Create(Sender: TComponent; device: string);
  52. begin
  53.      Seriale:=TLazSerial.Create(Sender);
  54.      Seriale.BaudRate:=br115200;
  55.      Seriale.DataBits:=db8bits;
  56.      Seriale.Device:=device;
  57.      Seriale.FlowControl:=fcNone;
  58.      Seriale.Parity:=pNone;
  59.      Seriale.StopBits:=sbOne;
  60.      Seriale.Active:=true;
  61. end;
  62.  
  63. function TEpson_TM_T70II.Stampa: boolean;
  64. begin
  65.      if Seriale.Active then
  66.      begin
  67.           Self.Inizializza();
  68.           Self.LineeBianche(5);
  69.           result:=true;
  70.      end else begin
  71.        result:=false;
  72.      end;
  73.  
  74. end;
  75.  
  76. destructor TEpson_TM_T70II.Free;
  77. begin
  78.      Seriale.Active:=false;
  79.      Seriale.Free;
  80. end;
  81.  
  82. end.
  83.  
  84.  


Error

TApplication.HandleException Access violation
  Stack trace:
  $003B9F08  TEPSON_TM_T70II__STAMPA,  line 65 of unit_epson_tm_t70ii.pas
  $00077E78  TFORM1__BUTTON1CLICK,  line 41 of unit1.pas
  $0024685C  TCONTROL__CLICK,  line 2711 of ./include/control.inc
  $0027946C  TBUTTONCONTROL__CLICK,  line 54 of ./include/buttoncontrol.inc
  $00279DFC  TCUSTOMBUTTON__CLICK,  line 169 of ./include/buttons.inc
  $00279334  TBUTTONCONTROL__WMDEFAULTCLICKED,  line 20 of ./include/buttoncontrol.inc
  $00043124
  $00234CB0  TWINCONTROL__WNDPROC,  line 5326 of ./include/wincontrol.inc
  $00336EBC  DELIVERMESSAGE,  line 112 of lclmessageglue.pas
  $00347BDC  GTK2WSBUTTON_CLICKED,  line 2435 of gtk2wsstdctrls.pp
  $76921AFC
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #129 on: August 10, 2016, 11:54:03 am »
hello,
yes xinyiman TLazserial only works on a Gui App  :( . But you can use synaser for your purpose.

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

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #130 on: August 10, 2016, 01:51:00 pm »
hello,
yes xinyiman TLazserial only works on a Gui App  :( . But you can use synaser for your purpose.

Friendly, J.P

How?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #131 on: August 10, 2016, 01:51:44 pm »
[posts crossed. Will post simple example sometime later today]
Yup.
And even with forms, synapse (which nowadays includes synaser) is probably a better choice.
Note synapse comes with classes, not components.
I use it all the time on my RPi's (ranging form 1 to 3)
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #132 on: August 10, 2016, 02:46:26 pm »
How?

There is a simple synaser console example here: http://turbocontrol.com/simpleserial.htm

There is an easy synapse console example here to send emails (and texts):  http://turbocontrol.com/easyemail.htm

I hope to update the second example in the next week as I'm using a newer version of it to send the current temperature in both emails and texts with a Raspberry Pi.
Regards,
Paul Breneman
www.ControlPascal.com

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #133 on: August 11, 2016, 11:40:31 am »
How?

There is a simple synaser console example here: http://turbocontrol.com/simpleserial.htm

There is an easy synapse console example here to send emails (and texts):  http://turbocontrol.com/easyemail.htm

I hope to update the second example in the next week as I'm using a newer version of it to send the current temperature in both emails and texts with a Raspberry Pi.

Thank you  ;)
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

PStechPaul

  • Jr. Member
  • **
  • Posts: 76
    • P S Technology, Inc.
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #134 on: August 23, 2016, 04:45:35 am »
I was able to install the TLazSerial component and build the demo GPS Simulator. I have a USB serial port designed in a custom data acquisition board, and when a Ctrl-T character is sent, it returns a stream of 240 unique character pairs, at 4800 characters per second, on a 57.6 kB connection. I was able to accomplish this with a TEST button and an OnClick handler.

It received and displayed them properly, as far as I can tell, so I'm happy with the component. I previously used SerialNG, but it did not work with Win10. Then I used ComDrv32, which I was able to use in a rather complex project, using Delphi 4 Pro. But I could not get those packages to install in Lazarus.

I am new to Lazarus, having only downloaded it yesterday. I was frustrated by the problems with the serial port components, but now I am happy to find this. I may post more details about my experience later, perhaps in a new thread.

 

TinyPortal © 2005-2018