Skip to content

Commit 529bf6b

Browse files
committed
Adding additional error codes for debugging of probe function
1 parent b12a03a commit 529bf6b

2 files changed

Lines changed: 50 additions & 34 deletions

File tree

ndicapi.cxx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,9 @@ ndicapiExport char* ndiErrorString(int errnum)
551551
"Too much environmental infrared",
552552
"Unrecognized error code",
553553
"Unrecognized error code",
554-
"Unable to read Flash EPROM",
555-
"Unable to write Flash EPROM",
556554
"Unable to erase Flash EPROM"
555+
"Unable to write Flash EPROM",
556+
"Unable to read Flash EPROM",
557557
};
558558

559559
static char* textarray_api[] = // values specific to the API
@@ -568,17 +568,29 @@ ndicapiExport char* ndiErrorString(int errnum)
568568
"Measurement System not found on specified port"
569569
};
570570

571+
static char* textarray_serial[] = // values specific to serial errors
572+
{
573+
"Serial DSR query failure",
574+
"Bad reply from measurement system",
575+
"System does not support Features.Firmware",
576+
"Command VER failed"
577+
};
578+
571579
if (errnum >= 0x00 && errnum <= 0x31)
572580
{
573581
return textarray_low[errnum];
574582
}
575-
else if (errnum <= 0xf6 && errnum >= 0xf1)
583+
else if (errnum >= 0xf1 && errnum <= 0xf6)
576584
{
577585
return textarray_high[errnum - 0xf1];
578586
}
579-
else if (errnum >= 0x100 && errnum <= 0x700)
587+
else if (errnum >= 0x0100 && errnum <= 0x0107)
588+
{
589+
return textarray_api[errnum - 0x0100];
590+
}
591+
else if (errnum >= 0x0200 && errnum <= 0x0203)
580592
{
581-
return textarray_api[(errnum >> 8) - 1];
593+
return textarray_serial[errnum - 0x200];
582594
}
583595

584596
return "Unrecognized error code";
@@ -723,7 +735,7 @@ ndicapiExport int ndiSerialProbe(const char* device)
723735
if (!ndiSerialCheckDSR(serial_port))
724736
{
725737
ndiSerialClose(serial_port);
726-
return NDI_PROBE_FAIL;
738+
return NDI_DSR_FAILURE;
727739
}
728740

729741
// set comm parameters to default, but decrease timeout to 0.1s
@@ -757,7 +769,7 @@ ndicapiExport int ndiSerialProbe(const char* device)
757769
if (n < 0)
758770
{
759771
ndiSerialClose(serial_port);
760-
return NDI_READ_ERROR;
772+
return errorCode;
761773
}
762774
else if (n == 0)
763775
{
@@ -769,7 +781,7 @@ ndicapiExport int ndiSerialProbe(const char* device)
769781
if (strncmp(init_reply, "RESETBE6F\r", 10) != 0)
770782
{
771783
ndiSerialClose(serial_port);
772-
return NDI_PROBE_FAIL;
784+
return NDI_BAD_REPLY;
773785
}
774786
// try to initialize a second time
775787
ndiSerialSleep(serial_port, 100);
@@ -809,7 +821,7 @@ ndicapiExport int ndiSerialProbe(const char* device)
809821
if (ndiSerialWrite(serial_port, "GETINFO:Features.Firmware.Version0492\r", strlen("GETINFO:Features.Firmware.Version0492\r")) != strlen("GETINFO:Features.Firmware.Version0492\r"))
810822
{
811823
ndiSerialClose(serial_port);
812-
return NDI_PROBE_FAIL;
824+
return NDI_NO_FEATURES_FIRMWARE;
813825
}
814826

815827
n = ndiSerialRead(serial_port, reply, 1023, false, &errorCode);
@@ -831,13 +843,13 @@ ndicapiExport int ndiSerialProbe(const char* device)
831843
(n = ndiSerialRead(serial_port, reply, 1023, false, &errorCode)) < 7)
832844
{
833845
ndiSerialClose(serial_port);
834-
return NDI_PROBE_FAIL;
846+
return NDI_COMMAND_VER_FAILED;
835847
}
836848
}
837849
else if (strncmp(reply, "Features", strlen("Features")) != 0)
838850
{
839851
ndiSerialClose(serial_port);
840-
return NDI_PROBE_FAIL;
852+
return NDI_BAD_REPLY;
841853
}
842854
}
843855

ndicapi.h

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,21 +1965,25 @@ ndicapiExport void* ndiHexDecode(void* data, const char* cp, int n);
19651965
#define NDI_FEATURES 0x25 /*!<\brief Failure to determine supported features*/
19661966

19671967
#define NDI_ENVIRONMENT 0xf1 /*!<\brief Too much environmental infrared */
1968-
1969-
#define NDI_EPROM_READ 0xf6 /*!<\brief Failure to read Flash EPROM */
1970-
#define NDI_EPROM_WRITE 0xf5 /*!<\brief Failure to write Flash EPROM */
1971-
#define NDI_EPROM_ERASE 0xf4 /*!<\brief Failure to erase Flash EPROM */
1968+
#define NDI_EEPROM_ERASE 0xf4 /*!<\brief Failure to erase Flash EEPROM */
1969+
#define NDI_EEPROM_WRITE 0xf5 /*!<\brief Failure to write Flash EEPROM */
1970+
#define NDI_EEPROM_READ 0xf6 /*!<\brief Failure to read Flash EEPROM */
19721971

19731972
/* error codes returned by the C api */
19741973

19751974
#define NDI_BAD_CRC 0x0100 /*!<\brief Bad CRC received from device */
1976-
#define NDI_OPEN_ERROR 0x0200 /*!<\brief Error opening serial device */
1977-
#define NDI_BAD_COMM 0x0300 /*!<\brief Bad communication parameters for host*/
1978-
#define NDI_TIMEOUT 0x0400 /*!<\brief Device took >5 secs to reply */
1979-
#define NDI_WRITE_ERROR 0x0500 /*!<\brief Device write error */
1980-
#define NDI_READ_ERROR 0x0600 /*!<\brief Device read error */
1981-
#define NDI_RESET_FAIL 0x0700 /*!<\brief Device failed to reset on break */
1982-
#define NDI_PROBE_FAIL 0x0800 /*!<\brief Device not found on specified port */
1975+
#define NDI_OPEN_ERROR 0x0101 /*!<\brief Error opening serial device */
1976+
#define NDI_BAD_COMM 0x0102 /*!<\brief Bad communication parameters for host*/
1977+
#define NDI_TIMEOUT 0x0103 /*!<\brief Device took >5 secs to reply */
1978+
#define NDI_WRITE_ERROR 0x0104 /*!<\brief Device write error */
1979+
#define NDI_READ_ERROR 0x0105 /*!<\brief Device read error */
1980+
#define NDI_RESET_FAIL 0x0106 /*!<\brief Device failed to reset on break */
1981+
#define NDI_PROBE_FAIL 0x0107 /*!<\brief Device not found on specified port */
1982+
1983+
#define NDI_DSR_FAILURE 0x0200 /*!<\brief Bad DSR query failure */
1984+
#define NDI_BAD_REPLY 0x0201 /*!<\brief Bad reply from measurement system */
1985+
#define NDI_NO_FEATURES_FIRMWARE 0x0202 /*!<\brief System doesn't support Features.Firmware */
1986+
#define NDI_COMMAND_VER_FAILED 0x0203 /*!<\brief VER command failed */
19831987
/*\}*/
19841988

19851989

@@ -2062,21 +2066,21 @@ ndicapiExport void* ndiHexDecode(void* data, const char* cp, int n);
20622066
/*\}*/
20632067

20642068
/* return values for handle status */
2065-
#define NDI_HANDLE_VALID 0x01
2066-
#define NDI_HANDLE_MISSING 0x02
2067-
#define NDI_HANDLE_DISABLED 0x04
2069+
#define NDI_HANDLE_VALID 0x01
2070+
#define NDI_HANDLE_MISSING 0x02
2071+
#define NDI_HANDLE_DISABLED 0x04
20682072

20692073
/* ndiGetTXPortStatus() and ndiGetPSTATPortStatus() return value bits */
20702074
/*\{*/
2071-
#define NDI_TOOL_IN_PORT 0x01
2072-
#define NDI_SWITCH_1_ON 0x02
2073-
#define NDI_SWITCH_2_ON 0x04
2074-
#define NDI_SWITCH_3_ON 0x08
2075-
#define NDI_INITIALIZED 0x10
2076-
#define NDI_ENABLED 0x20
2077-
#define NDI_OUT_OF_VOLUME 0x40 /* only for ndiGetGXPortStatus() */
2078-
#define NDI_PARTIALLY_IN_VOLUME 0x80 /* only for ndiGetGXPortStatus() */
2079-
#define NDI_CURRENT_DETECT 0x80 /* only for ndiGetPSTATPortStatus() */
2075+
#define NDI_TOOL_IN_PORT 0x01
2076+
#define NDI_SWITCH_1_ON 0x02
2077+
#define NDI_SWITCH_2_ON 0x04
2078+
#define NDI_SWITCH_3_ON 0x08
2079+
#define NDI_INITIALIZED 0x10
2080+
#define NDI_ENABLED 0x20
2081+
#define NDI_OUT_OF_VOLUME 0x40 /* only for ndiGetGXPortStatus() */
2082+
#define NDI_PARTIALLY_IN_VOLUME 0x80 /* only for ndiGetGXPortStatus() */
2083+
#define NDI_CURRENT_DETECT 0x80 /* only for ndiGetPSTATPortStatus() */
20802084
/*\}*/
20812085

20822086
/* ndiGetTXSystemStatus() return value bits */

0 commit comments

Comments
 (0)