Using sdOpen to share data between RTP and DKM. - VxWorks

This is a discussion on Using sdOpen to share data between RTP and DKM. - VxWorks ; Hi. I want to make a communication with DKM and RTP using shared data (sdLib). vxWorks 6.2. In the first, I wrote below code and built it. #include #include #include int main() { char buf[1024]; memset(buf, 0, 1024); off_t64 physAddress ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Using sdOpen to share data between RTP and DKM.

  1. Using sdOpen to share data between RTP and DKM.

    Hi.

    I want to make a communication with DKM and RTP using shared data
    (sdLib). vxWorks 6.2.
    In the first, I wrote below code and built it.

    #include
    #include
    #include

    int main()
    {
    char buf[1024];
    memset(buf, 0, 1024);
    off_t64 physAddress = 0;
    void** pVirtAddress = (void**)&buf;
    SD_ID sd;
    sd = sdOpen ("/sharedDataLion", 0, OM_CREATE | OM_EXCL, 1024,
    physAddress,
    (MMU_ATTR)SD_ATTR_RW,
    pVirtAddress);
    if(NULL == sd) {
    switch(errno) {
    case S_sdLib_VIRT_ADDR_PTR_IS_NULL:
    printf("pVirtAddress is NULL \n");
    break;
    case S_sdLib_ADDR_NOT_ALIGNED:
    printf("physAddress is not properly aligned \n");
    break;
    case S_sdLib_PHYS_ADDR_OUT_OF_RANGE:
    printf("physAddress exceeds physical address space \n");
    break;
    case S_sdLib_SIZE_IS_NULL:
    printf("size is NULL \n");
    break;
    case S_sdLib_INVALID_OPTIONS:
    printf("options is not a valid combination \n");
    break;
    case S_sdLib_VIRT_PAGES_NOT_AVAILABLE:
    printf("not enough virtual space left in system \n");
    break;
    case S_sdLib_PHYS_PAGES_NOT_AVAILABLE:
    printf("not enough physical memory left in system \n");
    break;
    default:
    printf("sd is NULL, and we don't know what is problem\n");
    break;
    }
    }
    printf("sdOpen sd id : %d\n", sd);
    while(1) {
    strcpy(buf, "hahaha\n");
    taskDelay(50);
    }
    return 0;
    }

    But the result is ....

    sd is NULL, and we don't know what is problem
    sdOpen sd id : 0

    Does anybode use sdOpen ?
    I'm googling about this subject, but there are a no sample code or
    information about it.
    except this link : http://groups.google.com.br/group/co...617b6bf90c1d35

    I think shared data + public semaphore is faster way to share data
    from DKM to RTP than msgQ, msgChannel.
    Am I wrong ?

    Thanks.

  2. Re: Using sdOpen to share data between RTP and DKM.

    On Jan 19, 3:16*pm, aeromarine wrote:
    > Hi.
    >
    > I want to make a communication with DKM and RTP using shared data
    > (sdLib). vxWorks 6.2.
    > In the first, I wrote below code and built it.




    > But the result is ....
    >
    > sd is NULL, and we don't know what is problem
    > sdOpen sd id : 0
    >


    Instead of "don't know what is problem", a good start would be to
    print the decimal value of .
    use: printf("%d", errno) ;
    Then, check the file /host/resource/tcl/VxWorksErrnoTbl.tcl
    for the meaning of the decimal value.
    ( is "c:\windriver\vxworks-6.3" or something like that
    depending on your setup).

    The fact that "sdOpen" is said to return only the mentioned error
    codes is misleading.
    Internally, sdOpen calls many other os functions, and each might fail
    with its own error code.


    Regards,
    Allen

  3. Re: Using sdOpen to share data between RTP and DKM.

    Hello,

    The problem is likely caused by you specifying the physical address of
    the shared data area to the address zero. Unless you want to use an
    unmapped-yet area of the physical memory you should replace
    physAddress with NULL in the sdOpen() call.

    Regarding the virtual address parameter note also that the
    documentation is misleading: what it means to say is that the address
    of the pVirtAddress parameter must be within the context of the RTP
    and be valid (i.e. it must correspond to memory that can be written).
    This parameter can not be left NULL since it must point to the address
    of the variable or memory area where the system will then return the
    virtual address (as visible by the RTP) of the shared data area.

    In your case the first word of the buffer will be used to store the
    virtual address of the shared data area but the buffer will not be
    used as the shared data area (I hope this is clear).

    Cheers,

    --
    PAD

+ Reply to Thread