Forum > General

[FOUND A SOLUTION] TLazSerial component has a major bug

<< < (2/3) > >>

Jurassic Pork:
Hello,

--- Quote from: Jurassic Pork on December 15, 2021, 07:11:24 pm ---it is strange ! what is your O.S ? Can you put all your code in attachment ? can you show me the first code with serialRXData event ?
Friendly, J.P

--- End quote ---

 8-)    If you don't answer to my questions or requests, i can't help you !

Friendly, J.P

Awesome Programmer:

--- Quote from: Jurassic Pork on January 08, 2022, 01:21:26 am ---Hello,

--- Quote from: Jurassic Pork on December 15, 2021, 07:11:24 pm ---it is strange ! what is your O.S ? Can you put all your code in attachment ? can you show me the first code with serialRXData event ?
Friendly, J.P

--- End quote ---

 8-)    If you don't answer to my questions or requests, i can't help you !

Friendly, J.P

--- End quote ---

My OS is Linux or Raspbian. I really can't put all of my code in an attachment. Besides, after my extensive research into my issue, I learned that Before my program even starts to process the incoming Serial Data, CPU usage goes up just by constantly receiving serial data at the port. So, the issue is within either TLazSerial or Synser.pas. All you have in your component is a THREAD just listening for Incoming Serial Data and waits for 100 million every time. That shouldn't cause this CPU usage spike.

I can show you SerialRXData code.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TDxCommDlg.MComportRxData(Sender: TObject);begin       if (ActiveUnit<>nil) then       begin              MComport.Synser.RecvBuffer(@RxMsg, 5);              ActiveUnit.Retreive;       end;end; 
This code is called constantly that my program within few seconds FREEZES and all the control is lost. At which point, I had to reboot my machine.

Remember, my program is only suppose to listen for incoming Serial Data. There are no Outgoing Serial Data.
Thanks, Pork.

Jurassic Pork:
hello,
have you try another software like cutecom to see if you have the same kind of problem ?  are you sure of your serial port ?

tetrastes:

--- Quote from: Awesome Programmer on January 10, 2022, 05:27:17 pm ---I can show you SerialRXData code.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TDxCommDlg.MComportRxData(Sender: TObject);begin       if (ActiveUnit<>nil) then       begin              MComport.Synser.RecvBuffer(@RxMsg, 5);              ActiveUnit.Retreive;       end;end; 
This code is called constantly that my program within few seconds FREEZES and all the control is lost. At which point, I had to reboot my machine.

--- End quote ---

Have you tried RecvBufferEx instead of RecvBuffer? From my experience (though I never used TLazSerial, but synaser directly), your usage of RecvBuffer is improper. At minimum your code, as it "is called constantly", will freeze your app when there is no data at port. I would recommended you to check the code of function RecvPacket at synaser.pas, after the line

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---//not drain CPU on large downloads... ;)
Oh, sorry, you have already. So you know how to use RecvBuffer properly...

BosseB:
If all you want to do is receive serial data, then why don't you use the serial unit that ships with FreePascal and can do exactly what you need without all the extraneous fluff?
About a year or more ago I struggled with the serial port too and wrestled with TLazSerial, which brings in Synapse and if used in a console program won't even compile properly...

Look here in the official documentation.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version