LazSerial/Synser Error Codes lazarus / 21-General ---------------------------------------------------------------------- Wilko500 · 2024-11-20 20:52 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i        i:=LazSerial1.SynSer.RecvBufferEx(@RcvBuf,8,50);        If LazSerial1.SynSer.LastError <> 0 Then // 9997 Then            //Timeout            Begin            WriteLn('Error in Get Serial No: Loop=' + IntToStr(iLoop) + ' - ' + IntToStr(k) + '  Error= ' + IntToStr(LazSerial1.SynSer.LastError));            End  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Error in Get Serial No: Loop=33 - 1  Error=25 ---------------------------------------------------------------------- dsiders · 2024-11-20 21:17 Quote from: Wilko500 on November 20, 2024, 09:52:21 pmI 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 · 2024-11-20 21:44 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. ---------------------------------------------------------------------- dsiders · 2024-11-20 21:55 Quote from: Wilko500 on November 20, 2024, 10:44:22 pmThank 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 · 2024-11-20 22:07 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. ---------------------------------------------------------------------- dsiders · 2024-11-20 22:36 Quote from: Wilko500 on November 20, 2024, 11:07:14 pmInteresting.  So I find dRemovErr = -25, /*tried to remove an open driver*/ Look further. 25 is out of memory. ---------------------------------------------------------------------- Thaddy · 2024-11-21 11:29 Yes, look further: he wrote -25 not 25. (is the same as 231, shortint vs byte valued) ---------------------------------------------------------------------- tetrastes · 2024-11-21 11:53 Synaser.pas: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i interface. . .    {:Returns the descriptive text associated with ErrorCode. You need this     method only in special cases. Description of LastError is now accessible     through the LastErrorDesc property.}    class function GetErrorDesc(ErrorCode: integer): string;. . .implementation. . .class function TBlockSerial.GetErrorDesc(ErrorCode: integer): string;begin  Result:= '';  case ErrorCode of    sOK:               Result := 'OK';    ErrAlreadyOwned:   Result := 'Port owned by other process';{HGJ}    ErrAlreadyInUse:   Result := 'Instance already in use';    {HGJ}    ErrWrongParameter: Result := 'Wrong parameter at call';     {HGJ}    ErrPortNotOpen:    Result := 'Instance not yet connected'; {HGJ}    ErrNoDeviceAnswer: Result := 'No device answer detected';  {HGJ}    ErrMaxBuffer:      Result := 'Maximal buffer length exceeded';    ErrTimeout:        Result := 'Timeout during operation';    ErrNotRead:        Result := 'Reading of data failed';    ErrFrame:          Result := 'Receive framing error';    ErrOverrun:        Result := 'Receive Overrun Error';    ErrRxOver:         Result := 'Receive Queue overflow';    ErrRxParity:       Result := 'Receive Parity Error';    ErrTxFull:         Result := 'Tranceive Queue is full';  end;  if Result = '' then  begin    Result := SysErrorMessage(ErrorCode);  end;end; Thus Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i WriteLn('Error in Get Serial No: Loop=' + IntToStr(iLoop) + ' - ' + IntToStr(k) + '  Error= ' + LazSerial1.SynSer.LastErrorDesc);