Exemple #1
2
int main1()
{
    int handle, status;
    uint32_t *ip, *pBuf;
    uint32_t maxEvBlk = 4;
    // uint64_t split = 230;
    uint64_t split = 100;


    printf("\nEvent I/O tests...\n");
    status = evOpen("/tmp/firstEventTestC.ev", "s", &handle);
    printf ("    Opened /tmp/firstEventTest.ev, status = %d\n", status);

    status = evIoctl(handle, "N", (void *) (&maxEvBlk));
    printf ("    Changed max events/block to %d, status = %#x\n", maxEvBlk, status);

    status = evIoctl(handle, "S", (void *) (&split));
    printf ("    Changed split to %d, status = %#x\n", split, status);

    printf ("    Write dictionary, status = %d\n",status);
    status = evWriteDictionary(handle, dictionary);

    pBuf = makeFirstEvent(1);

    printf ("    Write first event, status = %d\n",status);
    status = evWriteFirstEvent(handle, pBuf);

    ip = makeEvent();

    printf ("    Write event 1, status = %d\n",status);
    status = evWrite(handle, ip);

    printf ("    Write event 2, status = %d\n",status);
    status = evWrite(handle, ip);

    printf ("    Write event 3, status = %d\n",status);
    status = evWrite(handle, ip);

    status = evClose(handle);
    printf ("    Closed file, status = %d\n\n", status);

    free(pBuf);
    free(ip);
}
int main1() {
    int status, nevents, nwords;
    int i, maxEvBlk = 2;
    int *ip, *pBuf, *dict, dictLen, bufLen;
    size_t bufSize = 10000;
    char eventBuffer[4*bufSize];
    pthread_t  tid;
    struct timespec wait = {0, 10000L}; /* .00001 sec */

    memset(eventBuffer, 0, 4*bufSize);


    printf("\nEvent I/O tests to BUFFER (%p) ...\n", eventBuffer);
    status = evOpenBuffer(eventBuffer, bufSize, "w", &handle);

    status = evIoctl(handle, "N", (void *) (&maxEvBlk));
    printf ("    Changed max events/block to %d, status = %#x\n", maxEvBlk, status);

    status = evWriteDictionary(handle, dictionary);
    printf ("    Write dictionary to buffer, status = %#x\n\n", status);

    /* Launch thread to close */
    pthread_create(&tid, NULL, closeThread, (void *)NULL);

    while (1) {
        /* write 1 event to buffer */
        status = evWrite(handle, data1);
        if (status != S_SUCCESS) {
            printf ("    error in write, status = %#x\n\n", status);
            break;
        }
        nanosleep(&wait, NULL);
    }
}
Exemple #3
0
int main(int argc, char **argv)
{
    int handle, status, nevents, nwords, debug=0;
    uint32_t *buffer;
    int i, maxEvBlk = 2;
    char *filename;


    /* The beginning "|" tells evio to open a pipe and write to that
     * so it goes to the stdin of evReadPipe. */
    filename = "|evReadPipe";
    filename = "-";
    

    if (debug) printf("Write to program = %s\n", filename+1);

    status = evOpen(filename, "w", &handle);
    if (debug) printf ("    Opened file, status = %d\n", status);

    status = evWriteDictionary(handle, dictionary);

    buffer = makeEvent();

    if (debug) printEvent(1, buffer);


    for (i=0; i < 3; i++) {
        status = evWrite(handle, buffer);
        if (debug) printf ("    Wrote event to file status = %d\n",status);
    }

    status = evClose(handle);
    if (debug) printf ("    evWritePipe: closed file, status = %d\n\n", status);
 
    free(buffer);
}
Exemple #4
0
int main()
{
    int i, handle, status, sendFd, maxEvBlk=2;
    pthread_t tid;
    // char stuff[128];


    printf("Try running Receiver thread\n");
      
    /* run receiver thread */
    pthread_create(&tid, NULL, receiverThread, (void *) NULL);

    printf("Sending thd: sleep for 2 seconds\n");
    
    /* give it a chance to start */
    sleep(2);

    /* Create sending socket */
    sendFd = createSendFd();

    printf("Sending thd: socket fd = %d\n\n", sendFd);

    printf("\nSending thd: event I/O tests to socket (%d)\n", sendFd);
    status = evOpenSocket(sendFd, "w", &handle);
    
    printf("Sending thd: sleep for 1 more seconds\n");
    
    /* give it a chance to start */
    sleep(1);
    
    printf ("Sending thd: opened socket, status = %#x\n", status);

    
    status = evIoctl(handle, "N", (void *) (&maxEvBlk));
    printf ("Sending thd: changed max events/block to %d, status = %d\n", maxEvBlk, status);
    

    /* target block size = 8 header + 16 event words */
    i = 40;
    status = evIoctl(handle, "B", &i);
    if (status == S_EVFILE_BADSIZEREQ) {
        printf("Sending thd: bad value for target block size given\n");
        exit(0);
    }
    else if (status != S_SUCCESS) {
        printf("Sending thd: error setting target block size\n");
        exit(0);
    }
    printf ("Sending thd: changed target block size to %d, status = %d\n", i, status);


    /* buffer size = 2-8 headers + 16 event words or */
    
    i = 48;
    status = evIoctl(handle, "W", &i);
    if (status == S_EVFILE_BADSIZEREQ) {
        printf("Sending thd: bad value for buffer size given\n");
        exit(0);
    }
    else if (status != S_SUCCESS) {
        printf("Sending thd: error setting buffer size\n");
        exit(0);
    }
    printf ("Sending thd: changed buffer size to %d, status = %d\n", i, status);
    

    status = evWriteDictionary(handle, dictionary);
    printf ("Sending thd: write dictionary to socket, status = %d\n\n", status);

//    printf ("Sending thd: will write ** MED (16 word) ** ev to socket, status = %d\n",status);
//    status = evWrite(handle, evBuf_16);
    for (i=0; i < 4; i++) {
        printf("\nevtestSock: write little event %d ...\n", (i+1));
        status = evWrite(handle, evBuf_8);
        if (status != S_SUCCESS) {
            printf("Error in evWrite(), status = %x\n", status);
            exit(0);
        }
//        printf("\nEnter to continue\n");
//        gets(stuff);
    }

//    printf ("Sending thd: will write ** LITTLE (8 word) ** ev to socket, status = %d\n",status);
//    status = evWrite(handle, evBuf_8);

    printf ("Sending thd: will write ** BIG (18 word) ** ev to socket, status = %d\n",status);
    status = evWrite(handle, evBuf_18);

    printf ("Sending thd: will write ** HUGE (20 word) ** ev to socket, status = %d\n",status);
    status = evWrite(handle, evBuf_20);

    printf ("Sending thd: Call close()\n");
    status = evClose(handle);
    printf ("Sending thd: closed send socket, status %#x, wait 2 seconds\n\n", status);

    /* Don't exit the program before the receiver thread can do its stuff. */
    sleep(2);

    /* Close socket */
    close(sendFd);

    return(0);
}