Recent

Author Topic: How do I use SYNASER?  (Read 28564 times)

Hopestation

  • Full Member
  • ***
  • Posts: 181
How do I use SYNASER?
« on: July 06, 2011, 03:28:25 pm »
Hi.

I am trying to communicate with an external measuring instrument, via a USB connection, which is linked to Port COM6 on Windows XP PC.

I can do this with Windows HyperTerminal but it has a limitation on the number of line of data that it can read, so I have to create an alternative which will read up to 10,000 lines of data.
I am hoping that I can do this in Lazarus.

I have the following problems:

  Required Flow Control is NONE, synaser only offers Hardware or Software Handshake.

  This is not a modem so I assume that there will be no Dial or Ringing Tones.

  I have tried converting the Delphi Modem example and set the required Baud rate, etc. but when I try to connect I get a Time Out error.

How do I solve these?

Thanks

Roger

VicFer

  • New member
  • *
  • Posts: 9
Re: How do I use SYNASER?
« Reply #1 on: July 06, 2011, 08:55:40 pm »
Hi
did you try

yourTblockserial.Config(yourbaudrate,8,'N',SB1,False,False)

it turns off hard and soft flow controls.

Bye

Hopestation

  • Full Member
  • ***
  • Posts: 181
Re: How do I use SYNASER?
« Reply #2 on: July 08, 2011, 12:23:19 pm »
Thanks, VicFer.

I haven't tried that. I will do it now.

Regards

Roger

Hopestation

  • Full Member
  • ***
  • Posts: 181
Re: How do I use SYNASER?
« Reply #3 on: July 10, 2011, 11:02:26 am »
When I looked, I already have the line you described so that isn't the problem.

Starting from the beginning:

  I have tried loading the project spdo/spdoserial/test/sertest.lpi.

  I get the message "Unable to find the unit of component class "Tspdoserial".

  I assume that I must solve this before I can procede. What have I done wrong?

  Thanks

Roger


CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: How do I use SYNASER?
« Reply #4 on: July 10, 2011, 11:17:39 am »
Looks like you need to find this unit and make sure it is in your projects path is all. Project|options|paths. Or maybe you need to be sure ALL the the necessary units are in your 'uses' clause.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12847
  • FPC developer.
Re: How do I use SYNASER?
« Reply #5 on: July 10, 2011, 04:36:32 pm »
When I looked, I already have the line you described so that isn't the problem.

Starting from the beginning:

  I have tried loading the project spdo/spdoserial/test/sertest.lpi.

  I get the message "Unable to find the unit of component class "Tspdoserial".

  I assume that I must solve this before I can procede. What have I done wrong?

Open the project, and add a dependancy of the project to the (installed) synapse component package.

Lazarus manages installed component paths automatically for you if you add proper dependancies to your project file.

Hopestation

  • Full Member
  • ***
  • Posts: 181
Re: How do I use SYNASER?
« Reply #6 on: July 18, 2011, 06:30:07 pm »
Hi.
I appear to be going round in circles. One problem just leads to another.

I have sdposerialLaz0.1.4 listed in the loaded packages, but when I try to recomplie the IDE I get a message that pack_powerpdf is missing.

Clicking on the file opens another window, "Lazreportpdfexport" which shows
Required packages
IDEIntf    - green
LCL         - green
pack_powerpdf(>=0.9.6)    - orange
lazreport    - green
FLC(>=1.0)    - green

I have tried searching for pack_powerpdf in the Lazarus directory, using Windows Explorer Search, without success.

Where is this missing file, why is it missing from the original download, and how do I install it?

Regards

Roger

mas steindorff

  • Hero Member
  • *****
  • Posts: 576
Re: How do I use SYNASER?
« Reply #7 on: July 19, 2011, 07:24:17 pm »
I'm using synaser the same way you what to without any issues.  it works with 9.28.2 and 9.30.?
I did not need to manually include anything else to get it to work on my windows system.  I also just drop a copy of the unit in my project dir so it does not work a component.
to debug your system, you may try creating just a small comm project.
Also, I found the portmon utility from www.sysinternals.com to be useful with the more advanced comm port issues.
some of my code...
Code: [Select]
  public
     sPort         : TblockSerial;
     CommName      : string;
     connected     : Boolean;
...
....xxx.Create()
sport := TblockSerial.create; 
connected  := FALSE; 
...
xxx.OpenCommPort(ComStr: string): Boolean;
begin
  result    := FALSE;
  if connected then exit;
  sPort.Connect(ComStr);
// org BS sPort.config(921600,8,'N',0,false,false);
sPort.config(230400,8,'N',0,false,not TRUE);   
...
procedure xxx.GetDataBlock;
var // str:string;
    waiting,len:integer;
begin
  waiting := sPort.WaitingData;
  if (waiting > 0) then
     begin  // pull data in from comm buffer
     len := RawBuffSize - raw.inpos;
     if (len < waiting) then   // if too big for my fifo then
         waiting := len;       // reduce to fit just the end of buffer this time
     len := sPort.RecvBuffer(@Raw.Buff[raw.inpos], waiting);
...
 xxx.Destroy;
  if connected then
     sport.CloseSocket;
  sport.free;
...
   
windows 10 &11, Ubuntu 21+ IDE 3.4 general releases

Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Re: How do I use SYNASER?
« Reply #8 on: July 23, 2011, 05:07:19 am »
There are some very simple examples using SynaSer here:
  http://www.turbocontrol.com/simpleserial.htm
Regards,
Paul Breneman
www.ControlPascal.com

Hopestation

  • Full Member
  • ***
  • Posts: 181
Re: How do I use SYNASER?
« Reply #9 on: July 24, 2011, 01:09:55 pm »
Hi, Mas and Paul.

Your replies were very helpful.

I have downloaded PortMon and it has been a big help.

I finally got the SerTest example in the SDPO download to connect to my serial device and tried comparing the setup information for connections by Hyperterminal, Delphi-4 and Laraus v0.9.29.

The big difference between Lazarus and the other two is in the IOCTL_SERIAL_SET_QUEUE_SIZE.

Dehphi-4 has: InSize: 4096  OutSize: 2048.  This program receives data.

Hyperterminal has: InSize: 8192  OutSize: 8192.  This program receives data.

Lazarus has: InSize: 4096  Outsize: 10.  This program doesn't receive data.

Is this the problem?

The SPDO Serial component does not have any settings for queue sizes.

How do I change this?

Another difference is that both of the working programs only send IOCTL_SERIAL_SET_WAIT_MASK and IOCTL_SERIAL_WAIT ON MASK once.

Lazarus sends it repeatedly until the terminal is closed. Is this all part of the same problem?

I looked at the example in the DlpTempG.pas which  Paul refered to. It has a call to GetSerialPortNames, which I thought would be a great help in simplifying the connection of my equipment without having to use Device Manager and checking the I/O manually. The compiler didn't recognise the call. I have SdpoSerial and SysUtils in the uses section. but not Synaser, which I assume is already specified in SdpoSer. Why doesn't the compiler recognise it?

Although there are two examples' .pas files, there are no .lfm or lpi files, so I cannot try them to see what they are doing.

If you can explain any of the above it will be a great help.

Regards

Roger

Hopestation

  • Full Member
  • ***
  • Posts: 181
Re: How do I use SYNASER?
« Reply #10 on: July 26, 2011, 08:23:27 pm »
Hi Again.

I found that GetSerialPortNames is in Synaser and it wasn't included by SDPO. Once I added it to the project the call worked.

Does anyone know why I can't get the receive to work?

Do I have to make changes in either Synaser or SDPO?

Regards

Roger

jma_sp

  • Full Member
  • ***
  • Posts: 154
  • El conocimiento si ocupa lugar.
Re: How do I use SYNASER?
« Reply #11 on: October 17, 2014, 01:30:25 pm »
Also it works with ANSISTRING How to translate to STRING? . How to obtain a returned string from AT+commands? I can specify port and connection values but unable to obtain returned data to show in a memo.
I have connected to a Nokia Phone via Hyperterminal and send/receive command as to AT+CGSN to obtain IMEI then i need to do same with FreePascal/Lazarus code send AT+CGSN and return value into a string.
Only send AT+CGSN or need to add #$0D / CRLF ????

Or more simple, send AT command and get OK or a numeric value returned. In don´t know if it return characteres or a numeric value.

Any idea?

« Last Edit: October 17, 2014, 01:38:29 pm by jma_sp »
Devuan Beowulf 3.0( JWM/ROX/iDesk) - Puppy Linux,  Haiku OS,.ReactOS 0.4.xx  - FreeDos .

mas steindorff

  • Hero Member
  • *****
  • Posts: 576
Re: How do I use SYNASER?
« Reply #12 on: October 17, 2014, 08:27:53 pm »
jma_sp
I mostly use the interface to transfer binary data but when some of that stream carry's a string (like a rev string) then I simply move the bytes in to a string one at a time and let the string's internal code handle the memory allocation, length, & string termination.
Code: [Select]
repeat
   str = str + char(Cdat[i]);
   inc(i);
Until ( #0 = Cdat[i]) or (i >= bytecount)  ;

As far as fixed return types, each AT command's response is different, some are ascii and some are binary. most follow the standard (see wiki) but some times a modem comes out that can do more than the standard so the manufacturer adds an extended command.  that also means that as far as the AT modem commands go , the <eos> is a feature of the modem you are talking to. some are ok if you send CRLF, others only like one or the other {CR or LF}. I've work with one that required each (configuration) message  start and end with either an esc char (#27) or ACK (#6).   Best to check it's documentation. 
As a receiver, you may find it simpler to just treat the input as binary at the synaser level and then sort/ separate the incoming stream in your software (byte by byte).  that way you are in full control of when each string ends and the next begins (i.e old school).

PS:I'm not familiar with the AT+CGSM option. it may be the (phone's) interface is being defined above and beyond the modem level so you can follow one of the newer standards. 

windows 10 &11, Ubuntu 21+ IDE 3.4 general releases

 

TinyPortal © 2005-2018