VOC Optimation
[owSlave2.git] / tools_cmd / rwOW / owerr.c
index e26a97a..76c5176 100644 (file)
-//---------------------------------------------------------------------------
-// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
-// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-// Except as contained in this notice, the name of Dallas Semiconductor
-// shall not be used except as stated in the Dallas Semiconductor
-// Branding Policy.
-//---------------------------------------------------------------------------
-//
-// owerr.c - Library functions for error handling with 1-Wire library
-//
-// Version: 1.00
-//
-
-#include <string.h>
-#ifndef _WIN32_WCE
-#include <stdio.h>
-#endif
-#ifdef _WIN64
-#include <stdio.h>
-#endif
-#include "ownet.h"
-
-#ifndef SIZE_OWERROR_STACK
-   #ifdef SMALL_MEMORY_TARGET
-      //for small memory, only hole 1 error
-      #define SIZE_OWERROR_STACK 1
-   #else
-      #define SIZE_OWERROR_STACK 10
-   #endif
-#endif
-
-//---------------------------------------------------------------------------
-// Variables
-//---------------------------------------------------------------------------
-
-// Error Struct for holding error information.
-// In DEBUG, this will also hold the line number and filename.
-typedef struct
-{
-   int owErrorNum;
-#ifdef DEBUG
-   int lineno;
-   char *filename;
-#endif
-} owErrorStruct;
-
-// Ring-buffer used for stack.
-// In case of overflow, deepest error is over-written.
-static owErrorStruct owErrorStack[SIZE_OWERROR_STACK];
-
-// Stack pointer to top-most error.
-static int owErrorPointer = 0;
-
-
-//---------------------------------------------------------------------------
-// Functions Definitions
-//---------------------------------------------------------------------------
-int owGetErrorNum(void);
-void owClearError(void);
-int owHasErrors(void);
-#ifdef DEBUG
-   void owRaiseError(int,int,char*);
-#else
-   void owRaiseError(int);
-#endif
-#ifndef SMALL_MEMORY_TARGET
-   void owPrintErrorMsg(FILE *);
-   void owPrintErrorMsgStd();
-   char *owGetErrorMsg(int);
-#endif
-
-
-//--------------------------------------------------------------------------
-// The 'owGetErroNum' returns the error code of the top-most error on the
-// error stack.  NOTE: This function has the side effect of popping the
-// current error off the stack.  All successive calls to 'owGetErrorNum'
-// will further clear the error stack.
-//
-// For list of error codes, see 'ownet.h'
-//
-// Returns:   int :  The error code of the top-most error on the stack
-//
-int owGetErrorNum(void)
-{
-   int i = owErrorStack[ owErrorPointer ].owErrorNum;
-   owErrorStack[ owErrorPointer ].owErrorNum = 0;
-   if(!owErrorPointer)
-      owErrorPointer = SIZE_OWERROR_STACK - 1;
-   else
-      owErrorPointer = (owErrorPointer - 1);
-   return i;
-}
-
-//--------------------------------------------------------------------------
-// The 'owClearError' clears all the errors.
-//
-void owClearError(void)
-{
-   owErrorStack[ owErrorPointer ].owErrorNum = 0;
-}
-
-//--------------------------------------------------------------------------
-// The 'owHasErrors' is a boolean test function which tests whether or not
-// a valid error is waiting on the stack.
-//
-// Returns:   TRUE (1) : When there are errors on the stack.
-//            FALSE (0): When stack's errors are set to 0, or NO_ERROR_SET.
-//
-int owHasErrors(void)
-{
-   if(owErrorStack[ owErrorPointer ].owErrorNum)
-      return 1; //TRUE
-   else
-      return 0; //FALSE
-}
-
-#ifdef DEBUG
-   //--------------------------------------------------------------------------
-   // The 'owRaiseError' is the method for raising an error onto the error
-   // stack.
-   //
-   // Arguments:  int err - the error code you wish to raise.
-   //             int lineno - DEBUG only - the line number where it was raised
-   //             char* filename - DEBUG only - the file name where it occured.
-   //
-   void owRaiseError(int err, int lineno, char* filename)
-   {
-      owErrorPointer = (owErrorPointer + 1) % SIZE_OWERROR_STACK;
-      owErrorStack[ owErrorPointer ].owErrorNum = err;
-      owErrorStack[ owErrorPointer ].lineno = lineno;
-      owErrorStack[ owErrorPointer ].filename = filename;
-   }
-#else
-   //--------------------------------------------------------------------------
-   // The 'owRaiseError' is the method for raising an error onto the error
-   // stack.
-   //
-   // Arguments:  int err - the error code you wish to raise.
-   //
-   void owRaiseError(int err)
-   {
-      owErrorPointer = (owErrorPointer + 1) % SIZE_OWERROR_STACK;
-      owErrorStack[ owErrorPointer ].owErrorNum = err;
-   }
-#endif
-
-
-// SMALL_MEMORY_TARGET - embedded microcontrollers, where these
-// messaging functions might not make any sense.
-#ifndef SMALL_MEMORY_TARGET
-   //Array of meaningful error messages to associate with codes.
-   //Not used on targets with low memory (i.e. PIC).
-   static char *owErrorMsg[125] =
-   {
-   /*000*/ "No Error Was Set",
-   /*001*/ "No Devices found on 1-Wire Network",
-   /*002*/ "1-Wire Net Reset Failed",
-   /*003*/ "Search ROM Error: Couldn't locate next device on 1-Wire",
-   /*004*/ "Access Failed: Could not select device",
-   /*005*/ "DS2480B Adapter Not Detected",
-   /*006*/ "DS2480B: Wrong Baud",
-   /*007*/ "DS2480B: Bad Response",
-   /*008*/ "Open COM Failed",
-   /*009*/ "Write COM Failed",
-   /*010*/ "Read COM Failed",
-   /*011*/ "Data Block Too Large",
-   /*012*/ "Block Transfer failed",
-   /*013*/ "Program Pulse Failed",
-   /*014*/ "Program Byte Failed",
-   /*015*/ "Write Byte Failed",
-   /*016*/ "Read Byte Failed",
-   /*017*/ "Write Verify Failed",
-   /*018*/ "Read Verify Failed",
-   /*019*/ "Write Scratchpad Failed",
-   /*020*/ "Copy Scratchpad Failed",
-   /*021*/ "Incorrect CRC Length",
-   /*022*/ "CRC Failed",
-   /*023*/ "Failed to acquire a necessary system resource",
-   /*024*/ "Failed to initialize system resource",
-   /*025*/ "Data too long to fit on specified device.",
-   /*026*/ "Read exceeds memory bank end.",
-   /*027*/ "Write exceeds memory bank end.",
-   /*028*/ "Device select failed",
-   /*029*/ "Read Scratch Pad verify failed.",
-   /*030*/ "Copy scratchpad complete not found",
-   /*031*/ "Erase scratchpad complete not found",
-   /*032*/ "Address read back from scrachpad was incorrect",
-   /*033*/ "Read page with extra-info not supported by this memory bank",
-   /*034*/ "Read page packet with extra-info not supported by this memory bank",
-   /*035*/ "Length of packet requested exceeds page size",
-   /*036*/ "Invalid length in packet",
-   /*037*/ "Program pulse required but not available",
-   /*038*/ "Trying to access a read-only memory bank",
-   /*039*/ "Current bank is not general purpose memory",
-   /*040*/ "Read back from write compare is incorrect, page may be locked",
-   /*041*/ "Invalid page number for this memory bank",
-   /*042*/ "Read page with CRC not supported by this memory bank",
-   /*043*/ "Read page with CRC and extra-info not supported by this memory bank",
-   /*044*/ "Read back from write incorrect, could not lock page",
-   /*045*/ "Read back from write incorrect, could not lock redirect byte",
-   /*046*/ "The read of the status was not completed.",
-   /*047*/ "Page redirection not supported by this memory bank",
-   /*048*/ "Lock Page redirection not supported by this memory bank",
-   /*049*/ "Read back byte on EPROM programming did not match.",
-   /*050*/ "Can not write to a page that is locked.",
-   /*051*/ "Can not lock a redirected page that has already been locked.",
-   /*052*/ "Trying to redirect a locked redirected page.",
-   /*053*/ "Trying to lock a page that is already locked.",
-   /*054*/ "Trying to write to a memory bank that is write protected.",
-   /*055*/ "Error due to not matching MAC.",
-   /*056*/ "Memory Bank is write protected.",
-   /*057*/ "Secret is write protected, can not Load First Secret.",
-   /*058*/ "Error in Reading Scratchpad after Computing Next Secret.",
-   /*059*/ "Load Error from Loading First Secret.",
-   /*060*/ "Power delivery required but not available",
-   /*061*/ "Not a valid file name.",
-   /*062*/ "Unable to Create a Directory in this part.",
-   /*063*/ "That file already exists.",
-   /*064*/ "The directory is not empty.",
-   /*065*/ "The wrong type of part for this operation.",
-   /*066*/ "The max len for this file is too small.",
-   /*067*/ "This is not a write once bank.",
-   /*068*/ "The file can not be found.",
-   /*069*/ "There is not enough space available.",
-   /*070*/ "There is not a page to match that bit in the bitmap.",
-   /*071*/ "There are no jobs for EPROM parts.",
-   /*072*/ "Function not supported to modify attributes.",
-   /*073*/ "Handle is not in use.",
-   /*074*/ "Tring to read a write only file.",
-   /*075*/ "There is no handle available for use.",
-   /*076*/ "The directory provided is an invalid directory.",
-   /*077*/ "Handle does not exist.",
-   /*078*/ "Serial Number did not match with current job.",
-   /*079*/ "Can not program EPROM because a non-EPROM part on the network.",
-   /*080*/ "Write protect redirection byte is set.",
-   /*081*/ "There is an inappropriate directory length.",
-   /*082*/ "The file has already been terminated.",
-   /*083*/ "Failed to read memory page of iButton part.",
-   /*084*/ "Failed to match scratchpad of iButton part.",
-   /*085*/ "Failed to erase scratchpad of iButton part.",
-   /*086*/ "Failed to read scratchpad of iButton part.",
-   /*087*/ "Failed to execute SHA function on SHA iButton.",
-   /*088*/ "SHA iButton did not return a status completion byte.",
-   /*089*/ "Write data page failed.",
-   /*090*/ "Copy secret into secret memory pages failed.",
-   /*091*/ "Bind unique secret to iButton failed.",
-   /*092*/ "Could not install secret into user token.",
-   /*093*/ "Transaction Incomplete: signature did not match.",
-   /*094*/ "Transaction Incomplete: could not sign service data.",
-   /*095*/ "User token did not provide a valid authentication response.",
-   /*096*/ "Failed to answer a challenge on the user token.",
-   /*097*/ "Failed to create a challenge on the coprocessor.",
-   /*098*/ "Transaction Incomplete: service data was not valid.",
-   /*099*/ "Transaction Incomplete: service data was not updated.",
-   /*100*/ "Unrecoverable, catastrophic service failure occured.",
-   /*101*/ "Load First Secret from scratchpad data failed.",
-   /*102*/ "Failed to match signature of user's service data.",
-   /*103*/ "Subkey out of range for the DS1991.",
-   /*104*/ "Block ID out of range for the DS1991",
-   /*105*/ "Password is enabled",
-   /*106*/ "Password is invalid",
-   /*107*/ "This memory bank has no read only password",
-   /*108*/ "This memory bank has no read/write password",
-   /*109*/ "1-Wire is shorted",
-   /*110*/ "Error communicating with 1-Wire adapter",
-   /*111*/ "CopyScratchpad failed: Ending Offset must go to end of page",
-   /*112*/ "WriteScratchpad failed: Ending Offset must go to end of page",
-   /*113*/ "Mission can not be stopped while one is not in progress",
-   /*114*/ "Error stopping the mission",
-   /*115*/ "Port number is outside (0,MAX_PORTNUM) interval",
-   /*116*/ "Level of the 1-Wire was not changed",
-   /*117*/ "Both the Read Only and Read Write Passwords must be set",
-   /*118*/ "Failure to change latch state."
-   /*119*/ "Could not open usb port through libusb",
-   /*120*/ "Libusb DS2490 port already opened",
-   /*121*/ "Failed to set libusb configuration",
-   /*122*/ "Failed to claim libusb interface",
-   /*123*/ "Failed to set libusb altinterface",
-   /*124*/ "No adapter found at this port number"
-   };
-
-   char *owGetErrorMsg(int err)
-   {
-      return owErrorMsg[err];
-   }
-
-#ifndef __C51__
-   //--------------------------------------------------------------------------
-   // The 'owPrintErrorMsg' is the method for printing an error from the stack.
-   // The destination for the print is specified by the argument, fileno, which
-   // can be stderr, stdout, or a log file.  In non-debug mode, the output is
-   // of the form:
-   // Error num: Error msg
-   //
-   // In debug-mode, the output is of the form:
-   // Error num: filename line#: Error msg
-   //
-   // NOTE: This function has the side-effect of popping the error off the stack.
-   //
-   // Arguments:  FILE*: the destination for printing.
-   //
-   void owPrintErrorMsg(FILE *filenum)
-   {
-   #ifdef DEBUG
-      int l = owErrorStack[ owErrorPointer ].lineno;
-      char *f = owErrorStack[ owErrorPointer ].filename;
-      int err = owGetErrorNum();
-      fprintf(filenum,"Error %d: %s line %d: %s\r\n",err,f,l,owErrorMsg[err]);
-   #else
-      int err = owGetErrorNum();
-      fprintf(filenum,"Error %d: %s\r\n",err,owErrorMsg[err]);
-   #endif
-   }
-#endif //__C51__
-
-   // Same as above, except uses default printf output
-   void owPrintErrorMsgStd()
-   {
-   #ifdef DEBUG
-      int l = owErrorStack[ owErrorPointer ].lineno;
-      char *f = owErrorStack[ owErrorPointer ].filename;
-      int err = owGetErrorNum();
-      printf("Error %d: %s line %d: %s\r\n",err,f,l,owErrorMsg[err]);
-   #else
-      int err = owGetErrorNum();
-      printf("Error %d: %s\r\n",err,owErrorMsg[err]);
-   #endif
-   }
-#endif
-
+//---------------------------------------------------------------------------\r
+// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining a\r
+// copy of this software and associated documentation files (the "Software"),\r
+// to deal in the Software without restriction, including without limitation\r
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+// and/or sell copies of the Software, and to permit persons to whom the\r
+// Software is furnished to do so, subject to the following conditions:\r
+//\r
+// The above copyright notice and this permission notice shall be included\r
+// in all copies or substantial portions of the Software.\r
+//\r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r
+// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES\r
+// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\r
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r
+// OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+// Except as contained in this notice, the name of Dallas Semiconductor\r
+// shall not be used except as stated in the Dallas Semiconductor\r
+// Branding Policy.\r
+//---------------------------------------------------------------------------\r
+//\r
+// owerr.c - Library functions for error handling with 1-Wire library\r
+//\r
+// Version: 1.00\r
+//\r
+\r
+#include <string.h>\r
+#ifndef _WIN32_WCE\r
+#include <stdio.h>\r
+#endif\r
+#ifdef _WIN64\r
+#include <stdio.h>\r
+#endif\r
+#include "ownet.h"\r
+\r
+#ifndef SIZE_OWERROR_STACK\r
+   #ifdef SMALL_MEMORY_TARGET\r
+      //for small memory, only hole 1 error\r
+      #define SIZE_OWERROR_STACK 1\r
+   #else\r
+      #define SIZE_OWERROR_STACK 10\r
+   #endif\r
+#endif\r
+\r
+//---------------------------------------------------------------------------\r
+// Variables\r
+//---------------------------------------------------------------------------\r
+\r
+// Error Struct for holding error information.\r
+// In DEBUG, this will also hold the line number and filename.\r
+typedef struct\r
+{\r
+   int owErrorNum;\r
+#ifdef DEBUG\r
+   int lineno;\r
+   char *filename;\r
+#endif\r
+} owErrorStruct;\r
+\r
+// Ring-buffer used for stack.\r
+// In case of overflow, deepest error is over-written.\r
+static owErrorStruct owErrorStack[SIZE_OWERROR_STACK];\r
+\r
+// Stack pointer to top-most error.\r
+static int owErrorPointer = 0;\r
+\r
+\r
+//---------------------------------------------------------------------------\r
+// Functions Definitions\r
+//---------------------------------------------------------------------------\r
+int owGetErrorNum(void);\r
+void owClearError(void);\r
+int owHasErrors(void);\r
+#ifdef DEBUG\r
+   void owRaiseError(int,int,char*);\r
+#else\r
+   void owRaiseError(int);\r
+#endif\r
+#ifndef SMALL_MEMORY_TARGET\r
+   void owPrintErrorMsg(FILE *);\r
+   void owPrintErrorMsgStd();\r
+   char *owGetErrorMsg(int);\r
+#endif\r
+\r
+\r
+//--------------------------------------------------------------------------\r
+// The 'owGetErroNum' returns the error code of the top-most error on the\r
+// error stack.  NOTE: This function has the side effect of popping the\r
+// current error off the stack.  All successive calls to 'owGetErrorNum'\r
+// will further clear the error stack.\r
+//\r
+// For list of error codes, see 'ownet.h'\r
+//\r
+// Returns:   int :  The error code of the top-most error on the stack\r
+//\r
+int owGetErrorNum(void)\r
+{\r
+   int i = owErrorStack[ owErrorPointer ].owErrorNum;\r
+   owErrorStack[ owErrorPointer ].owErrorNum = 0;\r
+   if(!owErrorPointer)\r
+      owErrorPointer = SIZE_OWERROR_STACK - 1;\r
+   else\r
+      owErrorPointer = (owErrorPointer - 1);\r
+   return i;\r
+}\r
+\r
+//--------------------------------------------------------------------------\r
+// The 'owClearError' clears all the errors.\r
+//\r
+void owClearError(void)\r
+{\r
+   owErrorStack[ owErrorPointer ].owErrorNum = 0;\r
+}\r
+\r
+//--------------------------------------------------------------------------\r
+// The 'owHasErrors' is a boolean test function which tests whether or not\r
+// a valid error is waiting on the stack.\r
+//\r
+// Returns:   TRUE (1) : When there are errors on the stack.\r
+//            FALSE (0): When stack's errors are set to 0, or NO_ERROR_SET.\r
+//\r
+int owHasErrors(void)\r
+{\r
+   if(owErrorStack[ owErrorPointer ].owErrorNum)\r
+      return 1; //TRUE\r
+   else\r
+      return 0; //FALSE\r
+}\r
+\r
+#ifdef DEBUG\r
+   //--------------------------------------------------------------------------\r
+   // The 'owRaiseError' is the method for raising an error onto the error\r
+   // stack.\r
+   //\r
+   // Arguments:  int err - the error code you wish to raise.\r
+   //             int lineno - DEBUG only - the line number where it was raised\r
+   //             char* filename - DEBUG only - the file name where it occured.\r
+   //\r
+   void owRaiseError(int err, int lineno, char* filename)\r
+   {\r
+      owErrorPointer = (owErrorPointer + 1) % SIZE_OWERROR_STACK;\r
+      owErrorStack[ owErrorPointer ].owErrorNum = err;\r
+      owErrorStack[ owErrorPointer ].lineno = lineno;\r
+      owErrorStack[ owErrorPointer ].filename = filename;\r
+   }\r
+#else\r
+   //--------------------------------------------------------------------------\r
+   // The 'owRaiseError' is the method for raising an error onto the error\r
+   // stack.\r
+   //\r
+   // Arguments:  int err - the error code you wish to raise.\r
+   //\r
+   void owRaiseError(int err)\r
+   {\r
+      owErrorPointer = (owErrorPointer + 1) % SIZE_OWERROR_STACK;\r
+      owErrorStack[ owErrorPointer ].owErrorNum = err;\r
+   }\r
+#endif\r
+\r
+\r
+// SMALL_MEMORY_TARGET - embedded microcontrollers, where these\r
+// messaging functions might not make any sense.\r
+#ifndef SMALL_MEMORY_TARGET\r
+   //Array of meaningful error messages to associate with codes.\r
+   //Not used on targets with low memory (i.e. PIC).\r
+   static char *owErrorMsg[125] =\r
+   {\r
+   /*000*/ "No Error Was Set",\r
+   /*001*/ "No Devices found on 1-Wire Network",\r
+   /*002*/ "1-Wire Net Reset Failed",\r
+   /*003*/ "Search ROM Error: Couldn't locate next device on 1-Wire",\r
+   /*004*/ "Access Failed: Could not select device",\r
+   /*005*/ "DS2480B Adapter Not Detected",\r
+   /*006*/ "DS2480B: Wrong Baud",\r
+   /*007*/ "DS2480B: Bad Response",\r
+   /*008*/ "Open COM Failed",\r
+   /*009*/ "Write COM Failed",\r
+   /*010*/ "Read COM Failed",\r
+   /*011*/ "Data Block Too Large",\r
+   /*012*/ "Block Transfer failed",\r
+   /*013*/ "Program Pulse Failed",\r
+   /*014*/ "Program Byte Failed",\r
+   /*015*/ "Write Byte Failed",\r
+   /*016*/ "Read Byte Failed",\r
+   /*017*/ "Write Verify Failed",\r
+   /*018*/ "Read Verify Failed",\r
+   /*019*/ "Write Scratchpad Failed",\r
+   /*020*/ "Copy Scratchpad Failed",\r
+   /*021*/ "Incorrect CRC Length",\r
+   /*022*/ "CRC Failed",\r
+   /*023*/ "Failed to acquire a necessary system resource",\r
+   /*024*/ "Failed to initialize system resource",\r
+   /*025*/ "Data too long to fit on specified device.",\r
+   /*026*/ "Read exceeds memory bank end.",\r
+   /*027*/ "Write exceeds memory bank end.",\r
+   /*028*/ "Device select failed",\r
+   /*029*/ "Read Scratch Pad verify failed.",\r
+   /*030*/ "Copy scratchpad complete not found",\r
+   /*031*/ "Erase scratchpad complete not found",\r
+   /*032*/ "Address read back from scrachpad was incorrect",\r
+   /*033*/ "Read page with extra-info not supported by this memory bank",\r
+   /*034*/ "Read page packet with extra-info not supported by this memory bank",\r
+   /*035*/ "Length of packet requested exceeds page size",\r
+   /*036*/ "Invalid length in packet",\r
+   /*037*/ "Program pulse required but not available",\r
+   /*038*/ "Trying to access a read-only memory bank",\r
+   /*039*/ "Current bank is not general purpose memory",\r
+   /*040*/ "Read back from write compare is incorrect, page may be locked",\r
+   /*041*/ "Invalid page number for this memory bank",\r
+   /*042*/ "Read page with CRC not supported by this memory bank",\r
+   /*043*/ "Read page with CRC and extra-info not supported by this memory bank",\r
+   /*044*/ "Read back from write incorrect, could not lock page",\r
+   /*045*/ "Read back from write incorrect, could not lock redirect byte",\r
+   /*046*/ "The read of the status was not completed.",\r
+   /*047*/ "Page redirection not supported by this memory bank",\r
+   /*048*/ "Lock Page redirection not supported by this memory bank",\r
+   /*049*/ "Read back byte on EPROM programming did not match.",\r
+   /*050*/ "Can not write to a page that is locked.",\r
+   /*051*/ "Can not lock a redirected page that has already been locked.",\r
+   /*052*/ "Trying to redirect a locked redirected page.",\r
+   /*053*/ "Trying to lock a page that is already locked.",\r
+   /*054*/ "Trying to write to a memory bank that is write protected.",\r
+   /*055*/ "Error due to not matching MAC.",\r
+   /*056*/ "Memory Bank is write protected.",\r
+   /*057*/ "Secret is write protected, can not Load First Secret.",\r
+   /*058*/ "Error in Reading Scratchpad after Computing Next Secret.",\r
+   /*059*/ "Load Error from Loading First Secret.",\r
+   /*060*/ "Power delivery required but not available",\r
+   /*061*/ "Not a valid file name.",\r
+   /*062*/ "Unable to Create a Directory in this part.",\r
+   /*063*/ "That file already exists.",\r
+   /*064*/ "The directory is not empty.",\r
+   /*065*/ "The wrong type of part for this operation.",\r
+   /*066*/ "The max len for this file is too small.",\r
+   /*067*/ "This is not a write once bank.",\r
+   /*068*/ "The file can not be found.",\r
+   /*069*/ "There is not enough space available.",\r
+   /*070*/ "There is not a page to match that bit in the bitmap.",\r
+   /*071*/ "There are no jobs for EPROM parts.",\r
+   /*072*/ "Function not supported to modify attributes.",\r
+   /*073*/ "Handle is not in use.",\r
+   /*074*/ "Tring to read a write only file.",\r
+   /*075*/ "There is no handle available for use.",\r
+   /*076*/ "The directory provided is an invalid directory.",\r
+   /*077*/ "Handle does not exist.",\r
+   /*078*/ "Serial Number did not match with current job.",\r
+   /*079*/ "Can not program EPROM because a non-EPROM part on the network.",\r
+   /*080*/ "Write protect redirection byte is set.",\r
+   /*081*/ "There is an inappropriate directory length.",\r
+   /*082*/ "The file has already been terminated.",\r
+   /*083*/ "Failed to read memory page of iButton part.",\r
+   /*084*/ "Failed to match scratchpad of iButton part.",\r
+   /*085*/ "Failed to erase scratchpad of iButton part.",\r
+   /*086*/ "Failed to read scratchpad of iButton part.",\r
+   /*087*/ "Failed to execute SHA function on SHA iButton.",\r
+   /*088*/ "SHA iButton did not return a status completion byte.",\r
+   /*089*/ "Write data page failed.",\r
+   /*090*/ "Copy secret into secret memory pages failed.",\r
+   /*091*/ "Bind unique secret to iButton failed.",\r
+   /*092*/ "Could not install secret into user token.",\r
+   /*093*/ "Transaction Incomplete: signature did not match.",\r
+   /*094*/ "Transaction Incomplete: could not sign service data.",\r
+   /*095*/ "User token did not provide a valid authentication response.",\r
+   /*096*/ "Failed to answer a challenge on the user token.",\r
+   /*097*/ "Failed to create a challenge on the coprocessor.",\r
+   /*098*/ "Transaction Incomplete: service data was not valid.",\r
+   /*099*/ "Transaction Incomplete: service data was not updated.",\r
+   /*100*/ "Unrecoverable, catastrophic service failure occured.",\r
+   /*101*/ "Load First Secret from scratchpad data failed.",\r
+   /*102*/ "Failed to match signature of user's service data.",\r
+   /*103*/ "Subkey out of range for the DS1991.",\r
+   /*104*/ "Block ID out of range for the DS1991",\r
+   /*105*/ "Password is enabled",\r
+   /*106*/ "Password is invalid",\r
+   /*107*/ "This memory bank has no read only password",\r
+   /*108*/ "This memory bank has no read/write password",\r
+   /*109*/ "1-Wire is shorted",\r
+   /*110*/ "Error communicating with 1-Wire adapter",\r
+   /*111*/ "CopyScratchpad failed: Ending Offset must go to end of page",\r
+   /*112*/ "WriteScratchpad failed: Ending Offset must go to end of page",\r
+   /*113*/ "Mission can not be stopped while one is not in progress",\r
+   /*114*/ "Error stopping the mission",\r
+   /*115*/ "Port number is outside (0,MAX_PORTNUM) interval",\r
+   /*116*/ "Level of the 1-Wire was not changed",\r
+   /*117*/ "Both the Read Only and Read Write Passwords must be set",\r
+   /*118*/ "Failure to change latch state."\r
+   /*119*/ "Could not open usb port through libusb",\r
+   /*120*/ "Libusb DS2490 port already opened",\r
+   /*121*/ "Failed to set libusb configuration",\r
+   /*122*/ "Failed to claim libusb interface",\r
+   /*123*/ "Failed to set libusb altinterface",\r
+   /*124*/ "No adapter found at this port number"\r
+   };\r
+\r
+   char *owGetErrorMsg(int err)\r
+   {\r
+      return owErrorMsg[err];\r
+   }\r
+\r
+#ifndef __C51__\r
+   //--------------------------------------------------------------------------\r
+   // The 'owPrintErrorMsg' is the method for printing an error from the stack.\r
+   // The destination for the print is specified by the argument, fileno, which\r
+   // can be stderr, stdout, or a log file.  In non-debug mode, the output is\r
+   // of the form:\r
+   // Error num: Error msg\r
+   //\r
+   // In debug-mode, the output is of the form:\r
+   // Error num: filename line#: Error msg\r
+   //\r
+   // NOTE: This function has the side-effect of popping the error off the stack.\r
+   //\r
+   // Arguments:  FILE*: the destination for printing.\r
+   //\r
+   void owPrintErrorMsg(FILE *filenum)\r
+   {\r
+   #ifdef DEBUG\r
+      int l = owErrorStack[ owErrorPointer ].lineno;\r
+      char *f = owErrorStack[ owErrorPointer ].filename;\r
+      int err = owGetErrorNum();\r
+      fprintf(filenum,"Error %d: %s line %d: %s\r\n",err,f,l,owErrorMsg[err]);\r
+   #else\r
+      int err = owGetErrorNum();\r
+      fprintf(filenum,"Error %d: %s\r\n",err,owErrorMsg[err]);\r
+   #endif\r
+   }\r
+#endif //__C51__\r
+\r
+   // Same as above, except uses default printf output\r
+   void owPrintErrorMsgStd()\r
+   {\r
+   #ifdef DEBUG\r
+      int l = owErrorStack[ owErrorPointer ].lineno;\r
+      char *f = owErrorStack[ owErrorPointer ].filename;\r
+      int err = owGetErrorNum();\r
+      printf("Error %d: %s line %d: %s\r\n",err,f,l,owErrorMsg[err]);\r
+   #else\r
+      int err = owGetErrorNum();\r
+      printf("Error %d: %s\r\n",err,owErrorMsg[err]);\r
+   #endif\r
+   }\r
+#endif\r
+\r