Esempio n. 1
0
/*-----functions-----*/
THREAD(tone, arg){
VsPlayerInit();
VsSetVolume(1, 1);
VsBeepStart(2500);

NutSleep(1000);
VsBeepStop();
NutThreadExit();
NutThreadKill();
NutThreadDestroy();
}
Esempio n. 2
0
/*
 * Main application entry.
 */
    int play_stream(RADIO_STREAM rStream) {
        TCPSOCKET *sock;
        FILE *stream;
        u_long baud = DBG_BAUDRATE;
        u_long radio_ip = inet_addr(rStream.radio_ip);
        u_short tcpbufsiz = TCPIP_BUFSIZ;
        u_long rx_to = TCPIP_READTIMEOUT;
        u_short mss = TCPIP_MSS;
        u_long metaint;

        /*
         * Register UART device and assign stdout to it.
         */
        NutRegisterDevice(&DBG_DEVICE, 0, 0);
        freopen(DBG_DEVNAME, "w", stdout);
        _ioctl(_fileno(stdout), UART_SETSPEED, &baud);

        /*
         * Display system information.
         */
        printf("\n\nMedianut Tuotrial Part 3 - Nut/OS %s - " CC_STRING "\n", NutVersionString());
        printf("%u bytes free\n\n", NutHeapAvailable());

        /*
         * Register LAN device.
         */
        if (NutRegisterDevice(&DEV_ETHER, 0x8300, 5)) {
            puts("Error: No LAN device");
            for (; ;);
        }

        puts("configure LAN");
        /*
         * Configure LAN.
         */
        if (ConfigureLan("eth0")) {
            for (; ;);
        }

        puts("create a TCP socket");

        /*
         * Create a TCP socket.
         */
        if ((sock = NutTcpCreateSocket()) == 0) {
            puts("Error: Can't create socket");
            for (; ;);
        }

        puts("set socket options");

        /*
         * Set socket options. Failures are ignored.
         */
        if (NutTcpSetSockOpt(sock, TCP_MAXSEG, &mss, sizeof(mss)))
            printf("Sockopt MSS failed\n");
        if (NutTcpSetSockOpt(sock, SO_RCVTIMEO, &rx_to, sizeof(rx_to)))
            printf("Sockopt TO failed\n");
        if (NutTcpSetSockOpt(sock, SO_RCVBUF, &tcpbufsiz, sizeof(tcpbufsiz)))
            printf("Sockopt rxbuf failed\n");


        puts("connect the radio station");
        /*
         * Connect the radio station.
         */
        radio_ip = inet_addr(rStream.radio_ip);
        stream = ConnectStation(sock, rStream.radio_ip, rStream.radio_port, &metaint, rStream);
		send_message(rStream.radio_ip, rStream.radio_port, &metaint);
        /*
         * Play the stream.
         */
        if (stream) {
            puts("playing stream");
            PlayMp3Stream(stream, metaint);
            fclose(stream);
        }
        NutTcpCloseSocket(sock);


        NutThreadKill();
        NutThreadDestroy();
        return;
        puts("Reset me!");
        for (; ;);
}