Recent

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

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #195 on: December 08, 2016, 12:03:22 pm »
Hello,

I have RPi3 and PC with winXP. Try to send and receive datas via serial port. Connected GPIO via "shifter 3.3v" to PC. On Pc hyperterminal and on RPi3 form with button_connect, button_send, memo and one LazSerial1. In method RxData of LazSerial1 simply
<code>
str:=LazSerial1.ReadData;
memo1.Lines.Add(str);
</code>
After connection I click on button_send where is only: "LazSerial1.WriteData('aaa')"
and in hyperterminal I received 'aaa', so it works. But when I try to send something from hyperterminal to RPi3 then I get only something like empty line(no one visible sign), but every time I send from hyperterminal I notice that scrollbar of memo1 becomes smaller......
The same program in lazarus but compiled on win32 works well on PC.
Transmission:9600, 8,N,1, no flowcontrol.

Martin



Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #196 on: December 08, 2016, 12:14:47 pm »
run "sudo raspi-config", choose "advanced" choose  "A8 serial" and enable it. It is disabled by default. It says it is for a shell, but in fact you also need it to run software over serial. It is the serial interface!

Plz report back if it doesn't work. I personally use a patched synaser (from synapse distro) for serial work on RPi3
« Last Edit: December 08, 2016, 12:17:14 pm by Thaddy »
Specialize a type, not a var.

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #197 on: December 08, 2016, 09:59:23 pm »
Hi,

I have it already enabled, i'm sending from RPi to PC machine, but still can't receive any text from hyperterminal on PC.. I wonder maybe something is wrong with settings of hyperterminal, but why in this case two PC machines work well (I mean one have my program and second hyperterminal)?

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #198 on: December 08, 2016, 11:01:04 pm »
hello,
are you sure that Hyperterminal doesn't send a CRLF when you send something ? Unix doesn't like so much a CRLF. 
try to use a lazarus program with tlazserial or another windows serial program (teraterm for example) on your XP PC.

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

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #199 on: December 09, 2016, 12:59:54 pm »
Hi,

firstly thank you for your interest in this problem.
And secondly ;)

I've tested yesterday on PC hyperterminal and RPi3 with installed minicom. And it works but very very slow... I send few signs form PC hyperterminal e.g. 'www' (set local echo ON in order to see what should be sent) but minicom received only one 'w'. What else I have noticed, that during sending from PC to RPi both diodes of "shifter 3.3" (based on max3232) blinked, while from RPi to PC only one diode. Maybe it should be.
Connection looks like http://www.savagehomeautomation.com/projects/raspberry-pi-rs232-serial-interface-options-revisit.html.
The problem seems to be beyond Lazarus. I will test what you described Jurassic Pork.

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #200 on: December 09, 2016, 09:10:07 pm »
It was really beyond Lazarus and the solution my young padawans 8) isdescribed there:
1.http://www.hobbytronics.co.uk/raspberry-pi-serial-port

but it can be that by accident you own RPi3 where there is NOT /etc/inittab
and than you should in shell simply write:
sudo systemctl stop serial-getty@tty<YOUR SERIAL>.service
where <YOUR SERIAL> I have S0, so the whole MY line looks like:
sudo systemctl stop serial-getty@ttyS0.service
Now everything works. <SOLVED>

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #201 on: December 15, 2016, 11:12:10 am »
Hi!

Got my RS232 running pretty smooth and the bottom-message shows 'ReadCount : 25'.




From time time to it shows 'Can Read : '

I noticed that this happens at least as I scroll the mouse to scroll internet page.
After this, there apears the 'ReadCount : 25'.

Can someone explain th apearing of that 'CanRead : '?
 

to DIY or not to DIY

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #202 on: December 16, 2016, 02:30:08 pm »
hello,
if you have the message canread in the status bar of your program (if you use the same thing that in the sertest example) it is because you have a canread event :
Code: Pascal  [Select][+][-]
  1. procedure TFMain.SerialStatus(Sender: TObject; Reason: THookSerialReason;
  2.   const Value: string);
  3. begin
  4.   case Reason of
  5.     HR_SerialClose : StatusBar1.SimpleText := 'Port ' + Value + ' closed';
  6.     HR_Connect :   StatusBar1.SimpleText := 'Port ' + Value + ' connected';
  7.     HR_CanRead :   StatusBar1.SimpleText := 'CanRead : ' + Value ;
  8.     HR_CanWrite :  StatusBar1.SimpleText := 'CanWrite : ' + Value ;
  9.     HR_ReadCount : StatusBar1.SimpleText := 'ReadCount : ' + Value ;
  10.     HR_WriteCount : StatusBar1.SimpleText := 'WriteCount : ' + Value ;
  11.     HR_Wait :  StatusBar1.SimpleText := 'Wait : ' + Value ;
  12.   end ;            

if you want  to know why ,  look at in the synaser file    synaser.pas .  Or comment the line :
Code: Pascal  [Select][+][-]
  1.  HR_CanRead :   StatusBar1.SimpleText := 'CanRead : ' + Value ;

Friendly, J.P
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 #203 on: December 17, 2016, 12:45:59 pm »
Hi, Jurassic Pork!

 tnx, gonna check that next week.

Still working on my RS232, slowly...


But I recognized some things recarding to 'hang-ups'!

For example I got significant more hang-ups
by timer2.interval:= 250 [ms] in comparision to timer2.interval:= 200ms.

Now I experimentate with different lower intarvals, thing look to improve.

( Of course, I'm sure that the  sending/receiving-time + other-code-time-like Arduino-ADC, is safely short in comparision to the
  interval, otherwise you get problems.

Now it's running at interval:= 50ms...


For now, have a nice weekend!
to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #204 on: December 22, 2016, 09:35:03 pm »
Now I have placed on each a mini joystick a pottie.

So eacht stick has now X,Y,rotate and pushbutton.
to DIY or not to DIY

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #205 on: January 11, 2017, 10:20:51 am »
Hi,

working fine!


About my RS232 code: I don't like the delay in Laz, coded due of waiting for response/answer Arduino.
Even when Arduino's response is immidiately! ( Arduino's ADC-data ect.. allready processed and ready for Laz )

Gonna take another aproach: if a delay is needed, than better in the Arduino!



Timer50ms:
begin
1) read data from Arduino 
2) send to Arduino
3) 'process received data'
end;


//Other code:
procedure 'proces received data'


Before entering Timer for the first time, gonna do  ' 2) send to Arduino ' once, by  using kinda  boolean: bFirstEntering etc...   


Regards.










to DIY or not to DIY

Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #206 on: January 11, 2017, 10:40:08 am »
DSR/DSL? Timing is arbitrary, the device will signal.
Specialize a type, not a var.

jb007

  • Full Member
  • ***
  • Posts: 145
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #207 on: January 13, 2017, 11:26:12 am »
Hi, Thaddy.

Thank you and others for advice!

My Laz-RS232-code, definitely needs to be more sophisticated.
It works, no hangups etc, but it's jus not...you know!


At this moment, both pc-Lazarus and Arduini-mikroPascal are without delay.
Works fine!

to DIY or not to DIY

pieterroos

  • Newbie
  • Posts: 1
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #208 on: January 16, 2017, 10:27:54 am »
Hi
I am new to this forum, so excuse me if I do something wrong. I used TSdposerial component, but it is limited in the sense that it can only receive data in a string format. This is very annoying for me, as I use the component to create an interface between a PC and embedded systems. I often have to transfer binary data and the moment the embedded system transmit a 0x00 character, the data stream gets terminated on the PC side. So this morning I searched for a new serial port component and found LasSerial component. But it seems to work exactly the same as Tsdposerial component. Are there any way to receive binary data from the serial port without a 0x00 character interfering?

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #209 on: January 16, 2017, 05:45:20 pm »
hello,
with the sertest example of TLazserial if i replace the     procedure SerialRxData by this :

Code: Pascal  [Select][+][-]
  1. procedure TFMain.procedure TFMain.SerialRxData(Sender: TObject);
  2. var S,HexaS : string;
  3.     i : integer;
  4. begin
  5.   S := Serial.ReadData;
  6.   for I := 1 to Length(S) do begin
  7.     HexaS := HexaS + InttoHex(Ord(S[I]),2)+ ' ';
  8.   end;
  9. Memo.lines.Add(HexaS);

if i send this  (hexa bytes comma delimited) :  4B,4C,4D,4E,4F,50,51,52,53,54,55,56,57,58,59,5A,00
to the received port of Tlazserial component  I can see this in the received window of sertest :
Quote
4B 4C 4D 4E 4F 50 51 52 53 54 55 56
57 58 59 5A 00


Friendly J.P

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

 

TinyPortal © 2005-2018