Exemplo n.º 1
0
void printBeaconSystemConfiguration(OutputStream* outputStream) {
	Point* opponentPoint = getOpponentRobotPosition();
	
	Laser* laser1 = getLaser(LASER_INDEX_1);
	Laser* laser2 = getLaser(LASER_INDEX_2);
	
	printLaserStruct(outputStream, laser1);
	println(outputStream);
	printLaserStruct(outputStream, laser2);
	
	appendCRLF(outputStream);
	
	// Last Detection Time
	appendStringAndDecf(outputStream, "lastDetectionTime=", getLastDetectionTimeInMillis());
	println(outputStream);
	
	// Obsolete Detection Time Threshold
	appendStringAndDecf(outputStream, "obsoleteDetectionTimeThreshold=", getObsoleteDetectionTimeThreshold());
	println(outputStream);
	
	// Notify Time Delay
	appendStringAndDecf(outputStream, "notifyTimeDelay=", getNotifyTimeDelay());
	println(outputStream);
	
	// Opponent Position
	appendString(outputStream, "opponentPosition:");
	printPoint(outputStream, opponentPoint, " mm");
	
	// Distance between beacon
	appendStringAndDecf(outputStream, "distanceBetweenBeacon=", getDistanceBetweenBeacon());
	appendString(outputStream, " mm");
	println(outputStream);
	
	// Calibration Point
	appendString(outputStream, "calibrationPoint:");
	printPoint(outputStream, &(beaconSystem.calibrationPoint), " mm");
	
	// Opponent Position
	appendString(outputStream, "opponentPosition:");
	printPoint(outputStream, opponentPoint, " mm");
}
int receiverZigbeeTest(void) {
    /*
    char *macAdresse = "1";
    char *panId = "1620";
    char *channel = "100000";
    char *function = "0";
    char *adresse = "0";
    char *data;
    char receiveChar;
    char valide;
    int toto;
    */
    
    TRISB = 0;
    TRISB = 0;

    // Configure serialBuffer
    Buffer zigbeeBuffer;
    initBuffer(&zigbeeBuffer, SERIAL_PORT_ZIGBEE);
    setAndOpenSerialBuffer(&zigbeeBuffer);

    Buffer debugBuffer;
    initBuffer(&debugBuffer, SERIAL_PORT_DEBUG);
    setAndOpenSerialBuffer(&debugBuffer);

    setSerialBuffer(&debugBuffer);
    putString("Beacon Receiver start rs232\n");

    initPwmForServo(1500);    

    // Initialization of laserDetector
    // Laser 1
    initLaserDetectorStruct(
            LASER_INDEX_1,
            LASER_SERVO_INDEX_1,
            &getLaserPin1,
            SERVO_LASER_1_MAX_LEFT_POSITION_DEFAULT_VALUE, 
            SERVO_LASER_1_MAX_RIGHT_POSITION_DEFAULT_VALUE,
            SHORT_TRACKING_INTERVAL,
            BEACON_SERVO_1_FACTOR,
            BEACON_SERVO_1_INIT_COMPUTE_VALUE,
            BEACON_SERVO_1_ANGLE_DEGREE
    );
    // Laser 2
    initLaserDetectorStruct(
            LASER_INDEX_2,
            LASER_SERVO_INDEX_2,
            &getLaserPin2,
            SERVO_LASER_2_MAX_LEFT_POSITION_DEFAULT_VALUE,
            SERVO_LASER_2_MAX_RIGHT_POSITION_DEFAULT_VALUE,
            SHORT_TRACKING_INTERVAL,
            BEACON_SERVO_2_FACTOR,
            BEACON_SERVO_2_INIT_COMPUTE_VALUE,
            BEACON_SERVO_2_ANGLE_DEGREE
    );

    while (1) {
        int laserIndex;
        for (laserIndex = 0; laserIndex < LASER_COUNT; laserIndex++) {
            detectsLaser(laserIndex);
        }
        delay100us(5);

        char c = handleChar(&debugBuffer, false);
        if (c != 0) {
            putString("---------\n");
            Laser* laser1 = getLaser(LASER_INDEX_1);
            Laser* laser2 = getLaser(LASER_INDEX_2);
    
            printLaserStruct(&debugBuffer, laser1);
            println();
            printLaserStruct(&debugBuffer, laser2);
            clearBuffer(&debugBuffer);

            Point p = getPosition(DISTANCE_BETWEEN_BEACON);
            if (p.x != 0 && p.y != 0) {
                sendDec(p.x);
                putString(", ");
                sendDec(p.y);
                println();
            }    
        }
    }

    /*
    valide = 0;
    while (1) {
        if (U2STAbits.URXDA == 1){
                valide = getc();
                putc1 (valide);
        }
        if (U1STAbits.URXDA == 1){
                valide = getc1();
                putc (valide);
        }
    }
    */
}