RS-232 Error Conditions

If an error condition occurs during a call to any of the RS-232 Library functions, the function returns an error code. This code is a negative value that specifies the type of error that occurred.

You can call ReturnRS232Err to obtain the error code, either zero or a negative value, from the most recent function call in the current thread. If the most recent call was successful but an asynchronous write operation failed, ReturnRS232Err returns the error code from the asynchronous operation. To ensure that a particular function call succeeded, use the return value from that function call.

The rs232err global variable is the error code from the most recent function call or failed asynchronous write operation in your application, regardless of thread. In multithreaded applications, use ReturnRS232Err instead of rs232err.

The following table lists the currently defined error codes and their meanings.

RS-232 Library Error Codes

Note    Errors above 200 occur only on XModem function calls. The RS-232 Library records errors 261 through 265 when the maximum number of retries has been exhausted in trying to receive an XModem function packet.

For error code -1 (UnknownSystemError), call the GetRS232ErrorString function to obtain a specific Windows message string.
Code Error Message
-1 Unknown system error.
-2 Invalid port number.
-3 Port is not open.
-4 Unknown I/O error.
-5 Unexpected internal error.
-6 No serial port found.
-7 Cannot open port.
-8 A NULL pointer was passed when a non-NULL pointer was expected.
-11 Out of memory.
-12 Unable to allocate system resources.
-13 Invalid parameter.
-14 Invalid baud rate.
-24 Invalid parity.
-34 Invalid number of data bits.
-44 Invalid number of stop bits.
-90 Bad file handle.
-91 File I/O error.
-94 Invalid count; must be greater than or equal to 0.
-97 Invalid interrupt level.
-99 I/O operation timed out.
-104 Break time must be a positive value.
-114 Requested input queue size must be 0 or greater.
-124 Requested output queue size must be 0 or greater.
-151 General I/O error.
-152 Buffer parameter is NULL.
-257 Packet was sent, but no acknowledgment was received.
-258 Packet was not sent within retry limit.
-259 Packet was not received within retry limit.
-260 End of transmission character encountered when start of data character expected.
-261 Unable to read packet number.
-262 Inconsistent packet number.
-263 Unable to read packet data.
-264 Unable to read checksum.
-265 Checksum received did not match computed checksum.
-269 Packet size exceeds input queue size.
-300 Error opening file.
-301 Error reading file.
-302 Did not receive initial negative acknowledgment character.
-303 Did not receive acknowledgment after end of transmission character was sent.
-304 Error writing to file.
-305 Did not receive either a start of data or end of transmission character when expected.
-402 Transfer was canceled because CAN ASCII character was received.
-503 Invalid start delay.
-504 Invalid maximum number of retries.
-505 Invalid wait period.
-506 Invalid packet size.
-507 Unable to read Cyclical Redundancy Check.
-508 Cyclical Redundancy Check error.