コード例 #1
0
static void msd()
{
#if 1
    unsigned InEndPt = 1;
    unsigned OutEndPt = 1;
#else
    unsigned InEndPt = 1;
    unsigned OutEndPt = 2;
#endif
    unsigned char abBuf[512];
    int i;

//    set_config(1); - the culprit
    set_interface(0, 0);

#if 0
    /* Send an Get Max LUN request */
    abBuf[0] = 0;
    if (doctrl(VUSB_DIR_TO_HOST | VUSB_REQ_CLASS | VUSB_TO_INTERFACE,
               0xfe /* max lun */, 0, 1, 1, abBuf, "get max lun") >= 0)
        printf("max luns: %d\n",  abBuf[0]);
#endif

    for (i = 0; i < 3; i++)
    {
        printf("i=%d\n", i);

        /* Send an INQUIRY command to ep 2 */
        memset(abBuf, 0, sizeof(abBuf));
        memcpy(abBuf, "USBC", 4);
        *(uint32_t *)(&abBuf[4]) = 0x12330984 ;
        //abBuf[8]    = 0x08;
        abBuf[8]    = 0x24;
        abBuf[0xc]  = 0x80;
        abBuf[0xe]  = 0x06; /* cmd length */
        abBuf[0x0f] = 0x12; /* cmd - INQUIRY */
        abBuf[0x13] = 0x24;

        hex(abBuf, 31, "intquery req");
        if (send_bulk(OutEndPt, abBuf, 31) < 0)
            return;
        //usleep(15000);

        /* read result */
        memset(abBuf, 0, sizeof(abBuf));
    //printf("recv..\n");
        int cb = recv_bulk(InEndPt, abBuf, 36);
        hex(abBuf, cb, "inquiry result");

        /* sense? */
        memset(abBuf, 0, sizeof(abBuf));
        cb = recv_bulk(InEndPt, abBuf, 36);
        hex(abBuf, cb, "inquiry sense?");
        usleep(150000);
    }
}
コード例 #2
0
void printCurSettings(void)
{
    printf("old tty, speed %s baud, %d rows, %d columns\n",
    	baudtbl[sg.sg_ispeed & 0xF],wz.ws_row,wz.ws_col);
    printf("%seven %sodd %sraw %snl %secho %slcase %standem %stabs %scbreak\n",
    	dash[(sg.sg_flags & EVENP) == 0],
	dash[(sg.sg_flags & ODDP) == 0],
	dash[(sg.sg_flags & RAW) == 0],
	dash[(sg.sg_flags & NLDELAY) == 0],
	dash[(sg.sg_flags & ECHO) == 0],
	dash[(sg.sg_flags & LCASE) == 0],
	dash[(sg.sg_flags & TANDEM) == 0],
	dash[(sg.sg_flags & XTABS) == 0],
	dash[(sg.sg_flags & CBREAK) == 0]);
    printf("%stilde %sflusho %slitout %spass8 %snohang\n",
	dash[(localmode & LTILDE) == 0],
	dash[(localmode & LFLUSHO) == 0],
	dash[(localmode & LLITOUT) == 0],
	dash[(localmode & LPASS8) == 0],
	dash[(localmode & LNOHANG) == 0]);
    printf("%spendin %snoflsh\n",
	dash[(localmode & LPENDIN) == 0],
	dash[(localmode & LNOFLSH) == 0]);

    printf("erase  kill   werase rprnt  flush  lnext  susp   intr   quit   stop   eof\n");
    printf("%-7s",doctrl(sg.sg_erase));
    printf("%-7s",doctrl(sg.sg_kill));
    printf("%-7s",doctrl(ltc.t_werasc));
    printf("%-7s",doctrl(ltc.t_rprntc));
    printf("%-7s",doctrl(ltc.t_flushc));
    printf("%-7s",doctrl(ltc.t_lnextc));
    printf("%2s",doctrl(ltc.t_suspc));
    printf("/%2s  ",doctrl(ltc.t_dsuspc));
    printf("%-7s",doctrl(tc.t_intrc));
    printf("%-7s",doctrl(tc.t_quitc));
    printf("%2s",doctrl(tc.t_stopc));
    printf("/%2s  ",doctrl(tc.t_startc));
    printf("%-7s\n",doctrl(tc.t_eofc));
}
コード例 #3
0
void palm(void)
{
//    set_config(1); //skip this
//    reset_ep(6);

    /* This seems to be some kind of 'identify device' request. */
    uint8_t abVendor[0x14] = {0};
    int cb = doctrl(VUSB_DIR_TO_HOST | VUSB_REQ_VENDOR | VUSB_TO_ENDPOINT,
                    0x04, 0, 0, 0x14, abVendor, "vendor req");
    hex(abVendor, cb, "palm vendor req");

    /* read from ep 6. */
    uint8_t abBuf[512];
    memset(abBuf, 0, sizeof(abBuf));
    cb = recv_bulk(6, abBuf, 6);
    hex(abBuf, cb, "bulk 1");

    /* read from ep 6. */
    memset(abBuf, 0, sizeof(abBuf));
    cb = recv_bulk(6, abBuf, 22);
    hex(abBuf, cb, "bulk 2");

#if 0
    /* write to ep 6 */
    memset(abBuf, 0, sizeof(abBuf));
    abBuf[0] = 1;
    abBuf[1] = 2;
    abBuf[5] = 0x32;
    if (send_bulk(7, abBuf, 6) < 0)
        return;

    memset(abBuf, 0, sizeof(abBuf));
    abBuf[0] = 0x12;
    abBuf[1] = 1;
    if (send_bulk(7, abBuf, 8) < 0)
        return;

    memset(abBuf, 0, sizeof(abBuf));
    abBuf[1] = 0x20;
    abBuf[6] = 0x24;
    if (send_bulk(7, abBuf, 6) < 0)
        return;

    memset(abBuf, 0, sizeof(abBuf));
    abBuf[0] = 0xff;
    abBuf[1] = 0xff;
    abBuf[2] = 0xff;
    abBuf[3] = 0xff;
    abBuf[4] = 0x3c;
    abBuf[6] = 0x3c;
    abBuf[0x0f] = 1;
    abBuf[0x11] = 0x10;
    abBuf[0x15] = 0x10;
    abBuf[0x18] = 0x3c;
    abBuf[0x1a] = 0x3c;
    if (send_bulk(7, abBuf, 0x24) < 0)
        return;

    /* read from ep 6 */
    memset(abBuf, 0, sizeof(abBuf));
    cb = recv_bulk(6, abBuf, 64);
    hex(abBuf, cb, "bulk 3");

    /* read from ep 6. */
    memset(abBuf, 0, sizeof(abBuf));
    cb = recv_bulk(6, abBuf, 50);
    hex(abBuf, cb, "bulk 4");
#endif
}