コード例 #1
0
ファイル: drv_cli.c プロジェクト: akadamson/AQ32PlusF3
void cliPrint(char *str)
{
    uint32_t len;
    uint32_t oldTxed;
    uint32_t start;
    uint32_t txed;

    if (!(usbIsConnected() && usbIsConfigured()) || !str)
    {
	    return;
	}

	len     = strlen(str);

	txed    = 0;
	oldTxed = 0;

	start   = millis();

	while (txed < len && (millis() - start < USB_TIMEOUT))
	{
	    txed += CDC_Send_DATA((uint8_t*)str + txed, len - txed);

	    if (oldTxed != txed)
	    {
	        start = millis();
	    }

	    oldTxed = txed;
	}
}
コード例 #2
0
ファイル: usb_serial.cpp プロジェクト: CM-9xx/cm9xx
void USBSerial::write(const void *buf, uint32 len) {
    if (!(usbIsConnected() && usbIsConfigured())  //USB is not connected or fully configured
		|| !buf	//buf is empty!
		|| gbUsbVcpStatus == USB_PORT_CLOSE) { //[ROBOTIS]2012-12-19 to prevent USB Blocking issue!


    	return;
    }
//[ROBOTIS CHANGE][START]2012-12-14 fix some problems in transferring data to PC

    usbSendBytes((const uint8*)buf, len); // just call usbSendBytes()
  /*  uint32 txed = 0;
    uint32 old_txed = 0;
    uint32 start = millis();

    while (txed < len && (millis() - start < USB_TIMEOUT)) {
        txed += usbSendBytes((const uint8*)buf + txed, len - txed);
        if (old_txed != txed) {
            start = millis();
        }
        old_txed = txed;
    }*/
//[ROBOTIS CHANGE][END]2012-12-14 fix some problems in transferring data to PC

}
コード例 #3
0
ファイル: serial_usb_vcp.c プロジェクト: oleost/inav
static bool usbVcpFlush(vcpPort_t *port)
{
    uint32_t count = port->txAt;
    port->txAt = 0;

    if (count == 0) {
        return true;
    }

    if (!usbIsConnected() || !usbIsConfigured()) {
        return false;
    }

    uint32_t start = millis();
    uint8_t *p = port->txBuf;
    uint32_t txed = 0;
    while (count > 0) {
        txed = CDC_Send_DATA(p, count);
        count -= txed;
        p += txed;

        if (millis() - start > USB_TIMEOUT) {
            break;
        }
    }
    return count == 0;
}
コード例 #4
0
ファイル: maple-util.c プロジェクト: adamfeuer/WiShield
void serialUsbWrite(uint8 ch) {
    if(!(usbIsConnected() && usbIsConfigured())) {
        return;
    }
    uint16 status = 0;
    uint32 start = millis();
    while(status == 0 && (millis() - start <= USB_TIMEOUT)) {
        status = usbSendBytes(&ch, 1);
    }
}
コード例 #5
0
ファイル: usb_stm32f30x.c プロジェクト: robert-b/baseflight
void usbPrint(serialPort_t *instance, uint8_t c)
{
    uint32_t txed;
    uint32_t start = millis();

    if (!(usbIsConnected() && usbIsConfigured())) {
        return;
    }

    do {
        txed = CDC_Send_DATA((uint8_t*)&c, 1);
    } while (txed < 1 && (millis() - start < USB_TIMEOUT));

}
コード例 #6
0
ファイル: maple-util.c プロジェクト: adamfeuer/WiShield
void serialUsbWriteStr(const char *str) {
    if(!(usbIsConnected() && usbIsConfigured())) {
        return;
    }
    uint32 len = strlen(str);
    uint16 status = 0;
    uint16 oldstatus = 0;
    uint32 start = millis();
    while(status < len && (millis() - start < USB_TIMEOUT)) {
        status += usbSendBytes((uint8*)str+status, len-status);
        if(oldstatus != status) 
            start = millis();
        oldstatus = status;
    }
}
コード例 #7
0
ファイル: maple-util.c プロジェクト: adamfeuer/WiShield
void serialUsbWriteBuf(void *buf, uint32 size) {
    if(!(usbIsConnected() && usbIsConfigured())) {
        return;
    }
    if (!buf) {
        return;
    }
    uint16 status = 0;
    uint16 oldstatus = 0;
    uint32 start = millis();
    while(status < size && (millis() - start < USB_TIMEOUT)) {
        status += usbSendBytes((uint8*)buf+status, size-status);
        if(oldstatus != status) 
            start = millis();
        oldstatus = status;
    }
}
コード例 #8
0
ファイル: serial_usb_vcp.c プロジェクト: KiteAnton/betaflight
static void usbVcpWriteBuf(serialPort_t *instance, void *data, int count)
{
    UNUSED(instance);


    if (!(usbIsConnected() && usbIsConfigured())) {
        return;
    }

    uint32_t start = millis();
    for (uint8_t *p = data; count > 0; ) {
        uint32_t txed = CDC_Send_DATA(p, count);
        count -= txed;
        p += txed;

        if (millis() - start > USB_TIMEOUT) {
            break;
        }
    }
}
コード例 #9
0
ファイル: serial_usb_vcp.c プロジェクト: pqueiros/Triflight
static bool usbVcpFlush(vcpPort_t *port)
{
    uint8_t count = port->txAt;
    port->txAt = 0;

    if (count == 0) {
        return true;
    }
    if (!usbIsConnected() || !usbIsConfigured()) {
        return false;
    }
    
    uint32_t txed;
    uint32_t start = millis();

    do {
        txed = CDC_Send_DATA(port->txBuf, count);
    } while (txed != count && (millis() - start < USB_TIMEOUT));

    return txed == count;
}
コード例 #10
0
ファイル: usb_serial.cpp プロジェクト: CM-9xx/cm9xx
uint8 USBSerial::isConnected(void) {
    return usbIsConnected() && usbIsConfigured();
}
コード例 #11
0
ファイル: cli.c プロジェクト: jihlein/FF32mini
void cliCom(void)
{
	uint16_t index;

	char mvlkToggleString[5] = { 0, 0, 0, 0, 0 };

    if ((cliPortAvailable() && !validCliCommand))
    {
		cliQuery = cliPortRead();

        if (cliQuery == '#')                       // Check to see if we should toggle mavlink msg state
        {
	    	while (cliPortAvailable == false);

        	readStringCLI(mvlkToggleString, 5);

            if ((mvlkToggleString[0] == '#') &&
            	(mvlkToggleString[1] == '#') &&
                (mvlkToggleString[2] == '#') &&
                (mvlkToggleString[3] == '#'))
	    	{
	    	    if (systemConfig.mavlinkEnabled == false)
	    	    {
	    	 	    systemConfig.mavlinkEnabled  = true;
	    		    systemConfig.activeTelemetry = 0x0000;
	    		}
	    		else
	    		{
	    		    systemConfig.mavlinkEnabled = false;
	    	    }

	    	    if (mvlkToggleString[4] == 'W')
	    	    {
	                cliPortPrint("\nWriting EEPROM Parameters....\n");
	                writeSystemEEPROM();
	    	    }
	    	}
	    }
	}

	validCliCommand = false;

    if ((systemConfig.mavlinkEnabled == false) && (cliQuery != '#'))
    {
        switch (cliQuery)
        {
            ///////////////////////////////

            case 'a': // Rate PIDs
                cliPortPrintF("\nRoll Rate PID:  %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[ROLL_RATE_PID].P,
                    		                                                    systemConfig.PID[ROLL_RATE_PID].I,
                    		                                                    systemConfig.PID[ROLL_RATE_PID].D,
                    		                                                    systemConfig.PID[ROLL_RATE_PID].N);

                cliPortPrintF(  "Pitch Rate PID: %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[PITCH_RATE_PID].P,
                    		                                                    systemConfig.PID[PITCH_RATE_PID].I,
                    		                                                    systemConfig.PID[PITCH_RATE_PID].D,
                    		                                                    systemConfig.PID[PITCH_RATE_PID].N);

                cliPortPrintF(  "Yaw Rate PID:   %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[YAW_RATE_PID].P,
                    		                                                    systemConfig.PID[YAW_RATE_PID].I,
                    		                                                    systemConfig.PID[YAW_RATE_PID].D,
                    		                                                    systemConfig.PID[YAW_RATE_PID].N);
                cliQuery = 'x';
                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'b': // Attitude PIDs
                cliPortPrintF("\nRoll Attitude PID:  %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[ROLL_ATT_PID].P,
                   		                                                            systemConfig.PID[ROLL_ATT_PID].I,
                   		                                                            systemConfig.PID[ROLL_ATT_PID].D,
                   		                                                            systemConfig.PID[ROLL_ATT_PID].N);

                cliPortPrintF(  "Pitch Attitude PID: %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[PITCH_ATT_PID].P,
                   		                                                            systemConfig.PID[PITCH_ATT_PID].I,
                   		                                                            systemConfig.PID[PITCH_ATT_PID].D,
                   		                                                            systemConfig.PID[PITCH_ATT_PID].N);

                cliPortPrintF(  "Heading PID:        %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[HEADING_PID].P,
                   		                                                            systemConfig.PID[HEADING_PID].I,
                   		                                                            systemConfig.PID[HEADING_PID].D,
                   		                                                            systemConfig.PID[HEADING_PID].N);
                cliQuery = 'x';
                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'c': // Velocity PIDs
                cliPortPrintF("\nnDot PID:  %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[NDOT_PID].P,
                   		                                                   systemConfig.PID[NDOT_PID].I,
                   		                                                   systemConfig.PID[NDOT_PID].D,
                   		                                                   systemConfig.PID[NDOT_PID].N);

                cliPortPrintF(  "eDot PID:  %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[EDOT_PID].P,
                   		                                                   systemConfig.PID[EDOT_PID].I,
                   		                                                   systemConfig.PID[EDOT_PID].D,
                   		                                                   systemConfig.PID[EDOT_PID].N);

                cliPortPrintF(  "hDot PID:  %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[HDOT_PID].P,
                   		                                                   systemConfig.PID[HDOT_PID].I,
                   		                                                   systemConfig.PID[HDOT_PID].D,
                   		                                                   systemConfig.PID[HDOT_PID].N);
                cliQuery = 'x';
                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'd': // Position PIDs
                cliPortPrintF("\nN PID:  %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[N_PID].P,
                   		                                                systemConfig.PID[N_PID].I,
                   		                                                systemConfig.PID[N_PID].D,
                   		                                                systemConfig.PID[N_PID].N);

                cliPortPrintF(  "E PID:  %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[E_PID].P,
                   		                                                systemConfig.PID[E_PID].I,
                   		                                                systemConfig.PID[E_PID].D,
                   		                                                systemConfig.PID[E_PID].N);

                cliPortPrintF(  "h PID:  %8.4f, %8.4f, %8.4f, %8.4f\n", systemConfig.PID[H_PID].P,
                   		                                                systemConfig.PID[H_PID].I,
                   		                                                systemConfig.PID[H_PID].D,
                   		                                                systemConfig.PID[H_PID].N);
                cliQuery = 'x';
                validCliCommand = false;
              	break;

            ///////////////////////////////

            case 'e': // Loop Delta Times
               	cliPortPrintF("%7ld, %7ld, %7ld, %7ld, %7ld, %7ld, %7ld\n", deltaTime1000Hz,
                   		                                                    deltaTime500Hz,
                   		                                                    deltaTime100Hz,
                   		                                                    deltaTime50Hz,
                   		                                                    deltaTime10Hz,
                   		                                                    deltaTime5Hz,
                   		                                                    deltaTime1Hz);
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'f': // Loop Execution Times
               	cliPortPrintF("%7ld, %7ld, %7ld, %7ld, %7ld, %7ld, %7ld\n", executionTime1000Hz,
               	        			                                        executionTime500Hz,
               	        			                                        executionTime100Hz,
               	        			                                        executionTime50Hz,
               	        			                                        executionTime10Hz,
               	        			                                        executionTime5Hz,
               	        			                                        executionTime1Hz);
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'g': // 500 Hz Accels
            	cliPortPrintF("%9.4f, %9.4f, %9.4f\n", sensors.accel500Hz[XAXIS],
            			                               sensors.accel500Hz[YAXIS],
            			                               sensors.accel500Hz[ZAXIS]);
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'h': // 100 hz Earth Axis Accels
            	cliPortPrintF("%9.4f, %9.4f, %9.4f\n", earthAxisAccels[XAXIS],
            			                               earthAxisAccels[YAXIS],
            			                               earthAxisAccels[ZAXIS]);
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'i': // 500 hz Gyros
            	cliPortPrintF("%9.4f, %9.4f, %9.4f, %9.4f\n", sensors.gyro500Hz[ROLL ] * R2D,
            			                                      sensors.gyro500Hz[PITCH] * R2D,
            					                              sensors.gyro500Hz[YAW  ] * R2D,
            					                              mpu6000Temperature);
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'j': // 10 Hz Mag Data
                cliPortPrintF("%9.4f, %9.4f, %9.4f\n", sensors.mag10Hz[XAXIS],
                		                               sensors.mag10Hz[YAXIS],
                		                               sensors.mag10Hz[ZAXIS]);

            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'k': // Vertical Axis Variables
            	cliPortPrintF("%9.4f, %9.4f, %9.4f, %9.4f, %4ld, %9.4f\n", earthAxisAccels[ZAXIS],
            			                                                   sensors.pressureAlt50Hz,
            					                                           hDotEstimate,
            					                                           hEstimate,
            					                                           ms5611Temperature,
            					                                           aglRead());
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'l': // Attitudes
            	cliPortPrintF("%9.4f, %9.4f, %9.4f\n", sensors.attitude500Hz[ROLL ] * R2D,
            			                               sensors.attitude500Hz[PITCH] * R2D,
            			                               sensors.attitude500Hz[YAW  ] * R2D);
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'm': // Axis PIDs
            	cliPortPrintF("%9.4f, %9.4f, %9.4f\n", ratePID[ROLL ],
               			                               ratePID[PITCH],
               			                               ratePID[YAW  ]);
               	validCliCommand = false;
               	break;

            ///////////////////////////////

            case 'n': // GPS Data
               	switch (gpsDataType)
               	{
               	    ///////////////////////

               	    case 0:
               	        cliPortPrintF("%12ld, %12ld, %12ld, %12ld, %12ld, %12ld, %4d, %4d\n", gps.latitude,
               			                                                                      gps.longitude,
               			                                                                      gps.hMSL,
               			                                                                      gps.velN,
               			                                                                      gps.velE,
               			                                                                      gps.velD,
               			                                                                      gps.fix,
               			                                                                      gps.numSats);
               	        break;

               	    ///////////////////////

               	    case 1:
               	    	cliPortPrintF("%3d: ", gps.numCh);

               	    	for (index = 0; index < gps.numCh; index++)
               	    	    cliPortPrintF("%3d  ", gps.chn[index]);

               	    	cliPortPrint("\n");

               	    	break;

               	    ///////////////////////

               	    case 2:
               	    	cliPortPrintF("%3d: ", gps.numCh);

               	    	for (index = 0; index < gps.numCh; index++)
               	    		cliPortPrintF("%3d  ", gps.svid[index]);

               	    	cliPortPrint("\n");

               	    	break;

               	    ///////////////////////

               	    case 3:
               	    	cliPortPrintF("%3d: ", gps.numCh);

               	    	for (index = 0; index < gps.numCh; index++)
               	    		cliPortPrintF("%3d  ", gps.cno[index]);

               	    	cliPortPrint("\n");

               	    	break;

               	    ///////////////////////
               	}

               	validCliCommand = false;
                break;

            ///////////////////////////////

            case 'o':
                cliPortPrintF("%9.4f\n", batteryVoltage);

                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'p': // Primary Spektrum Raw Data
            	cliPortPrintF("%04X, %04X, %04X, %04X, %04X, %04X, %04X, %04X, %04X, %04X\n", primarySpektrumState.lostFrameCnt,
            			                                                                      primarySpektrumState.rcAvailable,
            			                                                                      primarySpektrumState.values[0],
            			                                                                      primarySpektrumState.values[1],
            			                                                                      primarySpektrumState.values[2],
            			                                                                      primarySpektrumState.values[3],
            			                                                                      primarySpektrumState.values[4],
            			                                                                      primarySpektrumState.values[5],
            			                                                                      primarySpektrumState.values[6],
            			                                                                      primarySpektrumState.values[7]);
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'q': // Not Used
                cliQuery = 'x';
               	validCliCommand = false;
               	break;

            ///////////////////////////////

			case 'r':
				if (flightMode == RATE)
					cliPortPrint("Flight Mode:RATE      ");
				else if (flightMode == ATTITUDE)
					cliPortPrint("Flight Mode:ATTITUDE  ");
				else if (flightMode == GPS)
					cliPortPrint("Flight Mode:GPS       ");

				if (headingHoldEngaged == true)
					cliPortPrint("Heading Hold:ENGAGED     ");
				else
					cliPortPrint("Heading Hold:DISENGAGED  ");

				switch (verticalModeState)
				{
					case ALT_DISENGAGED_THROTTLE_ACTIVE:
						cliPortPrint("Alt:Disenaged Throttle Active      ");

						break;

					case ALT_HOLD_FIXED_AT_ENGAGEMENT_ALT:
						cliPortPrint("Alt:Hold Fixed at Engagement Alt   ");

						break;

					case ALT_HOLD_AT_REFERENCE_ALTITUDE:
						cliPortPrint("Alt:Hold at Reference Alt          ");

						break;

					case VERTICAL_VELOCITY_HOLD_AT_REFERENCE_VELOCITY:
						cliPortPrint("Alt:Velocity Hold at Reference Vel ");

						break;

					case ALT_DISENGAGED_THROTTLE_INACTIVE:
						cliPortPrint("Alt:Disengaged Throttle Inactive   ");

						break;
				}

				if (rxCommand[AUX3] > MIDCOMMAND)
					cliPortPrint("Mode:Simple  ");
				else
					cliPortPrint("Mode:Normal  ");

				if (rxCommand[AUX4] > MIDCOMMAND)
					cliPortPrint("Emergency Bail:Active\n");
				else
					cliPortPrint("Emergency Bail:Inactive\n");

				validCliCommand = false;
				break;

			///////////////////////////////

			case 's': // Raw Receiver Commands
                if ((systemConfig.receiverType == SPEKTRUM) && (maxChannelNum > 0))
                {
		    		for (index = 0; index < maxChannelNum - 1; index++)
                         cliPortPrintF("%4ld, ", spektrumBuf[index]);

                    cliPortPrintF("%4ld\n", spektrumBuf[maxChannelNum - 1]);
                }
                else if ((systemConfig.receiverType == SPEKTRUM) && (maxChannelNum == 0))
                    cliPortPrint("Invalid Number of Spektrum Channels....\n");
		        else
		        {
		    		for (index = 0; index < 7; index++)
                        cliPortPrintF("%4i, ", ppmRxRead(index));

                    cliPortPrintF("%4i\n", ppmRxRead(7));
                }

            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 't': // Processed Receiver Commands
                for (index = 0; index < 7; index++)
                    cliPortPrintF("%8.2f, ", rxCommand[index]);

                cliPortPrintF("%8.2f\n", rxCommand[7]);

                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'u': // Command in Detent Discretes
            	cliPortPrintF("%s, ", commandInDetent[ROLL ] ? " true" : "false");
            	cliPortPrintF("%s, ", commandInDetent[PITCH] ? " true" : "false");
            	cliPortPrintF("%s\n", commandInDetent[YAW  ] ? " true" : "false");

                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'v': // ESC PWM Outputs
            	cliPortPrintF("%4ld, ", TIM2->CCR1 );
            	cliPortPrintF("%4ld, ", TIM2->CCR2 );
                cliPortPrintF("%4ld, ", TIM15->CCR1);
            	cliPortPrintF("%4ld, ", TIM15->CCR2);
            	cliPortPrintF("%4ld, ", TIM3->CCR1 );
            	cliPortPrintF("%4ld\n", TIM3->CCR2 );

            	validCliCommand = false;
                break;

            ///////////////////////////////

            case 'w': // Servo PWM Outputs
            	cliPortPrintF("%4ld, ", TIM4->CCR1);
            	cliPortPrintF("%4ld, ", TIM4->CCR2);
            	cliPortPrintF("%4ld, ", TIM4->CCR3);
            	cliPortPrintF("%4ld\n", TIM4->CCR4);

                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'x':
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'y': // ESC Calibration
            	escCalibration();

            	cliQuery = 'x';
            	break;

            ///////////////////////////////

            case 'z':
                cliPortPrintF("%5.2f, %5.2f\n", voltageMonitor(),
                		                        adcChannel());
                break;

            ///////////////////////////////

            ///////////////////////////////////////////////////////////////////////
            ///////////////////////////////////////////////////////////////////////
            ///////////////////////////////////////////////////////////////////////
            ///////////////////////////////////////////////////////////////////////

            ///////////////////////////////

            case 'A': // Read Roll Rate PID Values
                readCliPID(ROLL_RATE_PID);
                cliPortPrint( "\nRoll Rate PID Received....\n" );

            	cliQuery = 'a';
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'B': // Read Pitch Rate PID Values
                readCliPID(PITCH_RATE_PID);
                cliPortPrint( "\nPitch Rate PID Received....\n" );

            	cliQuery = 'a';
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'C': // Read Yaw Rate PID Values
                readCliPID(YAW_RATE_PID);
                cliPortPrint( "\nYaw Rate PID Received....\n" );

            	cliQuery = 'a';
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'D': // Read Roll Attitude PID Values
                readCliPID(ROLL_ATT_PID);
                cliPortPrint( "\nRoll Attitude PID Received....\n" );

            	cliQuery = 'b';
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'E': // Read Pitch Attitude PID Values
                readCliPID(PITCH_ATT_PID);
                cliPortPrint( "\nPitch Attitude PID Received....\n" );

            	cliQuery = 'b';
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'F': // Read Heading Hold PID Values
                readCliPID(HEADING_PID);
                cliPortPrint( "\nHeading PID Received....\n" );

            	cliQuery = 'b';
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'G': // Read nDot PID Values
                readCliPID(NDOT_PID);
                cliPortPrint( "\nnDot PID Received....\n" );

            	cliQuery = 'c';
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'H': // Read eDot PID Values
                readCliPID(EDOT_PID);
                cliPortPrint( "\neDot PID Received....\n" );

                cliQuery = 'c';
              	validCliCommand = false;
              	break;

            ///////////////////////////////

            case 'I': // Read hDot PID Values
                readCliPID(HDOT_PID);
                cliPortPrint( "\nhDot PID Received....\n" );

              	cliQuery = 'c';
              	validCliCommand = false;
              	break;

       	    ///////////////////////////////

            case 'J': // Read n PID Values
                readCliPID(N_PID);
                cliPortPrint( "\nn PID Received....\n" );

                cliQuery = 'd';
                validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'K': // Read e PID Values
                readCliPID(E_PID);
                cliPortPrint( "\ne PID Received....\n" );

                cliQuery = 'd';
                validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'L': // Read h PID Values
                readCliPID(H_PID);
                cliPortPrint( "\nh PID Received....\n" );

                cliQuery = 'd';
            	validCliCommand = false;
            	break;

            ///////////////////////////////

            case 'N': // Mixer CLI
                mixerCLI();

                cliQuery = 'x';
                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'O': // Receiver CLI
                receiverCLI();

                cliQuery = 'x';
                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'P': // Sensor CLI
               	sensorCLI();

               	cliQuery = 'x';
               	validCliCommand = false;
               	break;

            ///////////////////////////////

            case 'Q': // GPS Data Selection
            	gpsDataType = (uint8_t)readFloatCLI();

            	cliPortPrint("\n");

                cliQuery = 'n';
                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'R': // Reset to Bootloader
            	cliPortPrint("Entering Bootloader....\n\n");
            	delay(100);
            	systemReset(true);
            	break;

            ///////////////////////////////

            case 'S': // Reset System
            	cliPortPrint("\nSystem Reseting....\n\n");
            	delay(100);
            	systemReset(false);
            	break;

            ///////////////////////////////

            case 'T': // Telemetry CLI
                telemetryCLI();

                cliQuery = 'x';
             	validCliCommand = false;
             	break;

            ///////////////////////////////

            case 'U': // EEPROM CLI
                eepromCLI();

                cliQuery = 'x';
             	validCliCommand = false;
             	break;

            ///////////////////////////////

            case 'V': // Write Sensor EEPROM Parameters
                cliPortPrint("\nWriting Sensor EEPROM Parameters....\n\n");

                cliBusy = true;

                writeSensorEEPROM();

                cliBusy = false;

                cliQuery = 'x';
             	validCliCommand = false;
             	break;

            ///////////////////////////////

            case 'W': // Write System EEPROM Parameters
                cliPortPrint("\nWriting System EEPROM Parameters....\n\n");

                cliBusy = true;

                writeSystemEEPROM();

                cliBusy = false;

                cliQuery = 'x';
             	validCliCommand = false;
             	break;

            ///////////////////////////////

            case 'X': // Not Used
                cliQuery = 'x';
                validCliCommand = false;
                break;

            ///////////////////////////////

            case 'Y': // Not Used
                computeGeoMagElements();

                cliQuery = 'x';
                break;

            ///////////////////////////////

            case 'Z': // Not Used
                if (usbIsConfigured() == true)
                    cliPortPrint("\nUSB Configured TRUE\n");
                else
                    cliPortPrint("\nUSB Configured FALSE\n");

                if (usbIsConnected() == true)
                    cliPortPrint("\nUSB Connected TRUE\n");
                else
                    cliPortPrint("\nUSB Connected FALSE\n");

                cliQuery = 'x';
                break;

            ///////////////////////////////

            case '?': // Command Summary
            	cliBusy = true;

            	cliPortPrint("\n");
   		        cliPortPrint("'a' Rate PIDs                              'A' Set Roll Rate PID Data   AB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'b' Attitude PIDs                          'B' Set Pitch Rate PID Data  BB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'c' Velocity PIDs                          'C' Set Yaw Rate PID Data    CB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'d' Position PIDs                          'D' Set Roll Att PID Data    DB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'e' Loop Delta Times                       'E' Set Pitch Att PID Data   EB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'f' Loop Execution Times                   'F' Set Hdg Hold PID Data    FB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'g' 500 Hz Accels                          'G' Set nDot PID Data        GB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'h' 100 Hz Earth Axis Accels               'H' Set eDot PID Data        HB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'i' 500 Hz Gyros                           'I' Set hDot PID Data        IB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'j' 10 hz Mag Data                         'J' Set n PID Data           JB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'k' Vertical Axis Variable                 'K' Set e PID Data           KB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("'l' Attitudes                              'L' Set h PID Data           LB;P;I;D;windupGuard;dErrorCalc\n");
   		        cliPortPrint("\n");

   		        cliPortPrint("Press space bar for more, or enter a command....\n");

   		        while (cliPortAvailable() == false);

   		        cliQuery = cliPortRead();

   		        if (cliQuery != ' ')
   		        {
   		            validCliCommand = true;
   		            cliBusy = false;
   		        	return;
   		        }

   		        cliPortPrint("\n");
   		        cliPortPrint("'m' Axis PIDs                              'M' Not Used\n");
   		        cliPortPrint("'n' GPS Data                               'N' Mixer CLI\n");
   		        cliPortPrint("'o' Battery Voltage                        'O' Receiver CLI\n");
   		        cliPortPrint("'p' Primary Spektrum Raw Data              'P' Sensor CLI\n");
   		        cliPortPrint("'q' Not Used                               'Q' GPS Data Selection\n");
   		        cliPortPrint("'r' Mode States                            'R' Reset and Enter Bootloader\n");
   		        cliPortPrint("'s' Raw Receiver Commands                  'S' Reset\n");
   		        cliPortPrint("'t' Processed Receiver Commands            'T' Telemetry CLI\n");
   		        cliPortPrint("'u' Command In Detent Discretes            'U' EEPROM CLI\n");
   		        cliPortPrint("'v' Motor PWM Outputs                      'V' Write Sensor EEPROM Parameters\n");
   		        cliPortPrint("'w' Servo PWM Outputs                      'W' Write System EEPROM Parameters\n");
   		        cliPortPrint("'x' Terminate Serial Communication         'X' Not Used\n");
   		        cliPortPrint("\n");

   		        cliPortPrint("Press space bar for more, or enter a command....\n");

   		        while (cliPortAvailable() == false);

   		        cliQuery = cliPortRead();

   		        if (cliQuery != ' ')
   		        {
   		        	validCliCommand = true;
   		        	cliBusy = false;
   		        	return;
   		        }

   		        cliPortPrint("\n");
   		        cliPortPrint("'y' ESC Calibration                        'Y' Not Used\n");
   		        cliPortPrint("'z' ADC Values                             'Z' Not Used\n");
   		        cliPortPrint("                                           '?' Command Summary\n");
   		        cliPortPrint("\n");

  		        cliQuery = 'x';
  		        cliBusy = false;
   		        break;

                ///////////////////////////////
		}
    }
}
コード例 #12
0
ファイル: serial_usb_vcp.c プロジェクト: 4712/cleanflight
uint8_t usbVcpIsConnected(void)
{
    return usbIsConnected();
}
コード例 #13
0
ファイル: maple-util.c プロジェクト: adamfeuer/WiShield
uint8 serialUsbIsConnected(void) {
   return (usbIsConnected() && usbIsConfigured());
}