Recent

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

elcomportal

  • New Member
  • *
  • Posts: 16
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #90 on: August 12, 2015, 03:37:14 pm »
I get at the Com port strings ended with CR LF. Is there any event available when the line is completely received?
best regards
Torsten

tr_escape

  • Sr. Member
  • ****
  • Posts: 432
  • sector name toys | respect to spectre
    • Github:
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #91 on: August 12, 2015, 04:02:59 pm »
You can use that style:

But you have to check CR and LF chars in this event or in your buffer.

In this case com_some is my buffer.

Code: [Select]
procedure TfrmMain.Lazser1RxData(Sender: TObject);
var
  s : string;
begin
  //
   try
    s := Lazser1.ReadData;
    if s <> '' then
    begin
      wait_comm := False;
      if com_some = '' then
      begin
        LogAdd(mem_Log1, 'RCV<: ' + s);
        LogAdd(mem_Log2, 'RCV<: ' + StrToHex(s));
      end
      else
      begin
        LogAddStr(mem_Log1, s);
        LogAddStr(mem_Log2, StrToHex(s));
      end;
      com_some := com_some + s;
    end;
  except
    // LogAdd(mem_General,'Exp : ' );
  end;
end;

bambangfals

  • Newbie
  • Posts: 4
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #92 on: October 16, 2015, 02:46:37 am »
I have problem use lazserial

I want to send SMS with this AT COMMAND:
Code: Pascal  [Select][+][-]
  1. LazSerial1.WriteData('at+cmgs="PHONENUMBER"'+#13#10);
  2. LazSerial1.WriteData('Some text to send via sms');
  3. LazSerial1.WriteData(#26);

But there is a line break at the beginning of the text that I received.

Character that I received in my phone:
Code: Pascal  [Select][+][-]
  1.  
  2. Some text to send via sms

there "enter" in the beginning of the line.

Please help me for this bug and sory for my poor english.
Thx

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #93 on: October 16, 2015, 03:24:01 am »
I want to send SMS with this AT COMMAND:
Code: Pascal  [Select][+][-]
  1. LazSerial1.WriteData('at+cmgs="PHONENUMBER"'+#13#10);
  2. LazSerial1.WriteData('Some text to send via sms');
  3. LazSerial1.WriteData(#26);

But there is a line break at the beginning of the text that I received.
You send #13#10, the command expects:
Quote
AT+CMGS=<number><CR><message><CTRL-Z>
You add the #10 intentionally.

bambangfals

  • Newbie
  • Posts: 4
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #94 on: October 16, 2015, 04:00:06 am »
I want to send SMS with this AT COMMAND:
Code: Pascal  [Select][+][-]
  1. LazSerial1.WriteData('at+cmgs="PHONENUMBER"'+#13#10);
  2. LazSerial1.WriteData('Some text to send via sms');
  3. LazSerial1.WriteData(#26);

But there is a line break at the beginning of the text that I received.
You send #13#10, the command expects:
Quote
AT+CMGS=<number><CR><message><CTRL-Z>
You add the #10 intentionally.

Thanks leledumbo, I have changed #13#10 into #13 and it work like a charm.
You save my time :D  ;) ;)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #95 on: October 31, 2015, 08:36:46 pm »
Can be possible use lazserial as terminal like comport on delphi, cos i need type some commands and also received the respond device....

thanks.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #96 on: October 31, 2015, 11:25:12 pm »
hello,
eldonfsr, yes it is  normally possible .  Does your device response contains ending characters (ie : CRLF) ?
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #97 on: November 08, 2015, 01:37:50 am »
Ok my device return that character, the sample i look has two controls 1 for inputs and other for typing outputs but i need in the same control textboxedit can deal intputs and outputs.

thanks.

lonely_myp

  • New member
  • *
  • Posts: 9
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #98 on: November 17, 2015, 03:57:10 pm »
Hi.
I'm starting to learn to program, and I want to use the component.
standard example too complicated, could have that easier?

Just try to open existing port:
Code: Pascal  [Select][+][-]
  1. Serial.device:= '/dev/ttyS1';
  2. Serial.Open;
and got the error: Project raised exception class "External:SIGSEGV"

The standard example is started, but no data is sent or received.
The port is available, if I use the terminal, I can send and receive data.

tr_escape

  • Sr. Member
  • ****
  • Posts: 432
  • sector name toys | respect to spectre
    • Github:
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #99 on: November 17, 2015, 04:50:38 pm »
Hello ,

Maybe this prject helps you:

https://github.com/mehmetulukaya/muterm/blob/master/main.pas

Also I think you are using linux is your account member of dialout?


Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #100 on: November 18, 2015, 12:40:09 am »
hello,
lonely_myp, what kind of project do you want to make ? GUI or console app ? What is your O.S ? Windows, Linux , MAC ?

with  a TlazSerial component on your form try this  : 

Code: Pascal  [Select][+][-]
  1.   Serial.ShowSetupDialog;  
  2.   Serial.Open;    
  3.  

When the dialog setup appears, do you see your port (/dev/ttyS1) in the  choice of the port's combobox ?

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

lonely_myp

  • New member
  • *
  • Posts: 9
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #101 on: November 18, 2015, 09:27:33 am »
linux
Yes, account member of dialout, other programs (CuteCom) work with the device.

I want to write a simple GUI program, 2 buttons: "Open Port", "Send Data"
The program must send specific data and display the answer.

When the dialog setup appears, do you see your port
There is no dialogue, there is a window with an error.
exception 'Lazserialsetup.pas' line 211
ComComboBox1.Text: = ComPort.Device


Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   LazSerial, synaser;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     BOpen: TButton;
  17.     LazSerial1: TLazSerial;
  18.     procedure BOpenClick(Sender: TObject);
  19.   private
  20.     { private declarations }
  21.   public
  22.     { public declarations }
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.   Serial: TLazSerial;
  28.  
  29. implementation
  30.  
  31. {$R *.lfm}
  32.  
  33. { TForm1 }
  34.  
  35. procedure TForm1.BOpenClick(Sender: TObject);
  36. begin
  37.      Serial.ShowSetupDialog;
  38.      Serial.Open;
  39. end;
  40.  
  41. end.  ​
  42.  
« Last Edit: November 18, 2015, 09:42:30 am by lonely_myp »

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #102 on: November 18, 2015, 10:56:28 am »
what is your linux ( Ubuntu, Mint, other ?) ? version of your O.S ?
version of Lazarus and free pascal compiler ?
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

lonely_myp

  • New member
  • *
  • Posts: 9
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #103 on: November 18, 2015, 11:55:50 am »
ALT linux, It was based on Linux-Mandrake.
Lazarus 1.4.4
fpc 2.6.4

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #104 on: November 19, 2015, 01:03:01 am »
hello,
Quote
exception 'Lazserialsetup.pas' line 211
ComComboBox1.Text: = ComPort.Device

What kind of Exception ?
Debug your program and set a breakpoint at line 211 of Lazserialsetup.   Value of Comport.Device before exception ?
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

 

TinyPortal © 2005-2018