Recent

Author Topic: LazSerial/Synser Error Codes  (Read 1366 times)

Wilko500

  • Full Member
  • ***
  • Posts: 180
LazSerial/Synser Error Codes
« on: November 20, 2024, 09:52:21 pm »
I have been trying to locate the list of error codes returned as Last_Error by LazSerial/Synser procedure calls. I know it exists because I Have used it before but tonight spent ages searching going round and round in circles I just cannot find it. So frustrating.  While testing my serial comms to PV Inverter this code fragment records an error 25.  As you can see from my code fragment I initially tested for just timeout, ie code 9997, but still had problems.  This might be why.  Thus I want to review the error lists to see if there is a clue.  It might be that this error is generated by the OS. Please can someone provide a link too the LazSerial/Synser error code list.
Code: Pascal  [Select][+][-]
  1.        i:=LazSerial1.SynSer.RecvBufferEx(@RcvBuf,8,50);
  2.         If LazSerial1.SynSer.LastError <> 0 Then // 9997 Then
  3.             //Timeout
  4.             Begin
  5.             WriteLn('Error in Get Serial No: Loop=' + IntToStr(iLoop) + ' - ' + IntToStr(k) + '  Error= ' + IntToStr(LazSerial1.SynSer.LastError));
  6.             End  
Code: Pascal  [Select][+][-]
  1. Error in Get Serial No: Loop=33 - 1  Error=25
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

dsiders

  • Hero Member
  • *****
  • Posts: 1610
Re: LazSerial/Synser Error Codes
« Reply #1 on: November 20, 2024, 10:17:47 pm »
I have been trying to locate the list of error codes returned as Last_Error by LazSerial/Synser procedure calls. I know it exists because I Have used it before but tonight spent ages searching going round and round in circles I just cannot find it. So frustrating.

I don't know what you're trying to find - or where you're looking -  but try the source:

https://github.com/marado/synapse/blob/master/synaser.pas#L130

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: LazSerial/Synser Error Codes
« Reply #2 on: November 20, 2024, 10:44:22 pm »
Thank you.  This does indeed list error codes and lead me to a page of constants at http://synapse.ararat.cz/doc/help/synaser.html. Not quite what I was using before but confirms that error 25 is not an error generated by Synser. Must be an OS generated error.  Ummm!  I think I'll need to do some further research. but I don't fancy trying to track down a MacOs run time error.
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

dsiders

  • Hero Member
  • *****
  • Posts: 1610
Re: LazSerial/Synser Error Codes
« Reply #3 on: November 20, 2024, 10:55:42 pm »
Thank you.  This does indeed list error codes and lead me to a page of constants at http://synapse.ararat.cz/doc/help/synaser.html. Not quite what I was using before but confirms that error 25 is not an error generated by Synser. Must be an OS generated error.  Ummm!  I think I'll need to do some further research. but I don't fancy trying to track down a MacOs run time error.

I know nothing about macOS... but:

https://krypted.com/lists/comprehensive-list-of-mac-os-x-error-codes/

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: LazSerial/Synser Error Codes
« Reply #4 on: November 20, 2024, 11:07:14 pm »
Interesting.  So I find dRemovErr = -25, /*tried to remove an open driver*/  I am doing serial comms and that uses a driver but in the middle of a loop of 200 iterations when all the calls before and after this call to send data to inverter and receive its response, are ok makes little sense.
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

dsiders

  • Hero Member
  • *****
  • Posts: 1610
Re: LazSerial/Synser Error Codes
« Reply #5 on: November 20, 2024, 11:36:08 pm »
Interesting.  So I find dRemovErr = -25, /*tried to remove an open driver*/

Look further. 25 is out of memory.

Thaddy

  • Hero Member
  • *****
  • Posts: 19133
  • Glad to be alive.
Re: LazSerial/Synser Error Codes
« Reply #6 on: November 21, 2024, 12:29:02 pm »
Yes, look further: he wrote -25 not 25. ;D (is the same as 231, shortint vs byte valued)
« Last Edit: November 21, 2024, 12:33:27 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

tetrastes

  • Hero Member
  • *****
  • Posts: 762
Re: LazSerial/Synser Error Codes
« Reply #7 on: November 21, 2024, 12:53:03 pm »
Synaser.pas:
Code: Pascal  [Select][+][-]
  1. interface
  2. . . .
  3.     {:Returns the descriptive text associated with ErrorCode. You need this
  4.      method only in special cases. Description of LastError is now accessible
  5.      through the LastErrorDesc property.}
  6.     class function GetErrorDesc(ErrorCode: integer): string;
  7. . . .
  8. implementation
  9. . . .
  10. class function TBlockSerial.GetErrorDesc(ErrorCode: integer): string;
  11. begin
  12.   Result:= '';
  13.   case ErrorCode of
  14.     sOK:               Result := 'OK';
  15.     ErrAlreadyOwned:   Result := 'Port owned by other process';{HGJ}
  16.     ErrAlreadyInUse:   Result := 'Instance already in use';    {HGJ}
  17.     ErrWrongParameter: Result := 'Wrong parameter at call';     {HGJ}
  18.     ErrPortNotOpen:    Result := 'Instance not yet connected'; {HGJ}
  19.     ErrNoDeviceAnswer: Result := 'No device answer detected';  {HGJ}
  20.     ErrMaxBuffer:      Result := 'Maximal buffer length exceeded';
  21.     ErrTimeout:        Result := 'Timeout during operation';
  22.     ErrNotRead:        Result := 'Reading of data failed';
  23.     ErrFrame:          Result := 'Receive framing error';
  24.     ErrOverrun:        Result := 'Receive Overrun Error';
  25.     ErrRxOver:         Result := 'Receive Queue overflow';
  26.     ErrRxParity:       Result := 'Receive Parity Error';
  27.     ErrTxFull:         Result := 'Tranceive Queue is full';
  28.   end;
  29.   if Result = '' then
  30.   begin
  31.     Result := SysErrorMessage(ErrorCode);
  32.   end;
  33. end;

Thus
Code: Pascal  [Select][+][-]
  1. WriteLn('Error in Get Serial No: Loop=' + IntToStr(iLoop) + ' - ' + IntToStr(k) + '  Error= ' + LazSerial1.SynSer.LastErrorDesc);

 

TinyPortal © 2005-2018