how to add Add errno (user implemneted) to library ? - VxWorks

This is a discussion on how to add Add errno (user implemneted) to library ? - VxWorks ; We have differnet types of errno in VXWorks. And i want to know shall we add any new user defined errno to the library. And if possible please give me the details...

+ Reply to Thread
Results 1 to 2 of 2

Thread: how to add Add errno (user implemneted) to library ?

  1. how to add Add errno (user implemneted) to library ?

    We have differnet types of errno in VXWorks. And i want to know shall
    we add any new user defined errno to the library. And if possible
    please give me the details


  2. Re: how to add Add errno (user implemneted) to library ?

    On Jun 15, 2:45 pm, bhanu wrote:
    > We have differnet types of errno in VXWorks. And i want to know shall
    > we add any new user defined errno to the library. And if possible
    > please give me the details


    Hi Bhanu,
    I have not worked on this,but believe the given information below
    will help you.I got this below mentioned information from a previous
    query and reply in this group.
    ================================================== ==================
    How can i have my own errno's defined can any one help with the
    > procedure and also i by calling that no by printErrno it should be
    > able to display.




    You can define a global variable for error number, suppose myErrCode,
    And
    you
    have a constant array of string defined in some header file that
    contians
    the error message cooresponding to error number.You have a routine
    for
    printing the error message Suppose myErrMsgPrint(). This function will
    use
    the global variable myErrCode to print appropriate error message
    corresponding to the error number.
    In your source code where you want to use this error coding you need
    to set
    the value of myErrCode.In some other c source file(extern the global
    for
    error number myErrCode) where some error condition is triggered you
    just set


    global variable myErrcode to appropriate array index of your error
    message
    array.


    Here is some pseudo code --
    int myErrcode=0;


    char *myerrorMsg[3]={"NO ERROR","FILE OPEN ERROR","FILE READ ERROR"};


    void myErrMsgPrint(void)
    {
    printf("%s",myerrorMsg[myErrcode]);
    }


    //in some other C file
    extern int myErrcode;
    //this is a pseudo function showing the implementation of myerrocode
    void functionfileopen(void)
    {
    FILE *fp;
    fp=fopen("somefile","r");
    if(fp==NULL)
    {
    //here set the global error number
    myErrcode =1;//indicates file open erro
    return;
    }
    else
    myErrcode =0;


    }
    Now in the vxworks shell you can verify the value of myErrcode and
    call
    myErrMsgPrint to view appropriate error message.


    Thanks & Regards,
    Shibasis,

    Hi
    some more information on errno.

    VxWorks errno is composed of upper 16 bits indicating the library the
    error originates from, followed by 16 bits indicating specific error
    within that library.


    The definition of upper 16 bit library categories is located in
    header
    file target/h/vwModNum.h.


    For Example: If the errono number you get is 0xd003, then first you
    find this module number, here the upper 16 bit would be 0xd (decimal
    13) which corresponds to M_iosLib, you can then look up the specific
    error number in the library's own header -- in our example, we look
    up
    target/h/iosLib.h to find out what error 3 in iosLib means. I.e.,
    S_iosLib_INVALID_FILE_DESCRIPTOR


    Alternatively, if you have INCLUDE_STAT_SYM_TBL configured(while
    building the image) for your running target image you can look up the
    error by using printErrno() routine from the shell.
    ================================================== ======

    I hope that helps you.

    Regards,
    s.subbarayan



+ Reply to Thread