コード例 #1
0
void GetEEPRomData(uint8_t start, uint8_t stop, uint8_t * data) {
//	println_W("Getting eeprom page: ");p_int_W(start+DATASTART);print_W(" to ");p_int_W(stop+DATASTART);
	//WORD_VAL raw;
	uint8_t i = 0;
	if (start > stop) {
		//println_W("###ERROR eeprom");
		return;
	}
	int total = 0;
	do {
		total++;
		if (total > 5)
			return;
		LoadCorePacket(&downstreamPacketTemp);
		for (i = 0; i < (stop - start); i++) {
			//Writes over the old packet to avoid mis-reads
			downstreamPacketTemp.use.data[i] = data[i];
		}
		downstreamPacketTemp.use.head.Method = BOWLER_GET;
		downstreamPacketTemp.use.head.RPC = GetRPCValue(eepd);
		downstreamPacketTemp.use.data[0] = start + DATASTART;
		downstreamPacketTemp.use.data[1] = stop + DATASTART;
		downstreamPacketTemp.use.head.DataLegnth = 6;
		SendPacketToCoProc(&downstreamPacketTemp);
		buttonCheck(12);
	} while (downstreamPacketTemp.use.head.RPC != GetRPCValue(eepd));

	for (i = 0; i < (stop - start); i++) {
		data[i] = downstreamPacketTemp.use.data[i + 1];
	}
//	println_W("Rx<<");
//	printBowlerPacketDEBUG(&downstreamPacketTemp,WARN_PRINT);
}
コード例 #2
0
void CheckRev(void) {
	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.Method = BOWLER_GET;
	downstreamPacketTemp.use.head.RPC = GetRPCValue("_rev");
	downstreamPacketTemp.use.head.DataLegnth = 4;
	SendPacketToCoProc(&downstreamPacketTemp);
	if ((downstreamPacketTemp.use.data[0] == MAJOR_REV)
			&& (downstreamPacketTemp.use.data[1] == MINOR_REV)
			&& (downstreamPacketTemp.use.data[2] == FIRMWARE_VERSION)) {
		SetColor(0, 0, 1);
	} else {
		//SetColor(1, 0, 0);
		println_I("Rev. Check Failed! AVR:");
		p_int_I(downstreamPacketTemp.use.data[0]);
		print_I(".");
		p_int_I(downstreamPacketTemp.use.data[1]);
		print_I(".");
		p_int_I(downstreamPacketTemp.use.data[2]);
		print_I(" PIC:");
		p_int_I(MAJOR_REV);
		print_I(".");
		p_int_I(MINOR_REV);
		print_I(".");
		p_int_I(FIRMWARE_VERSION);

	}
}
コード例 #3
0
void LoadGACM(BowlerPacket * pack) {
	LoadCorePacket(pack);
	pack->use.head.Method = BOWLER_GET;
	pack->use.head.RPC = GetRPCValue("gacm");
	pack->use.head.DataLegnth = 4;
	SetCRC(&downstreamPacketTemp);
}
コード例 #4
0
boolean GetAllChanelValueFromPacket(BowlerPacket * Packet) {
    int32_t * data = (int32_t *) (&Packet->use.data[1]);
    if (getAllChanelValueHWPtr != NULL) {
        int i;
        int32_t tmp;
        getAllChanelValueHWPtr(data);
        for (i = 0; i < GetNumberOfIOChannels(); i++) {
            tmp = data[i];
            if(isOutputMode(GetChannelMode(i))==false){
            	setDataTableCurrentValue(i,tmp);
            }else{
                 if(GetChannelMode(i) == IS_SERVO){
                    tmp = GetServoPos(i);
                }else if(GetChannelMode(i)== IS_UART_RX){
                	setDataTableCurrentValue(i,tmp);
    			}else{
                    tmp = getBcsIoDataTable(i)->PIN.currentValue;
    			}
            }

            set32bit(Packet, tmp, (i*4)+1);

        }
        Packet->use.data[0]=(GetNumberOfIOChannels());
        Packet->use.head.RPC=GetRPCValue("gacv");
        Packet->use.head.DataLegnth = 4+1+(GetNumberOfIOChannels()*4);
    } else
        return false;
    FixPacket(Packet);
    return true;
}
コード例 #5
0
BOOL test__png(BowlerPacket * Packet) {
    printf("\r\nMy Overloaded RPC callback \r\n");
    Packet->use.head.Method = BOWLER_POST;
    Packet->use.head.RPC = GetRPCValue("Mpng");
    Packet->use.head.DataLegnth = 4;
    return TRUE;
}
コード例 #6
0
void setCoProcBrownOutMode(boolean b) {

	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.Method = BOWLER_CRIT;
	downstreamPacketTemp.use.head.RPC = GetRPCValue("_pwr");
	downstreamPacketTemp.use.head.DataLegnth = 4 + 1;
	downstreamPacketTemp.use.data[0] = b;
	SendPacketToCoProc(&downstreamPacketTemp);

}
コード例 #7
0
boolean GetIOChannelCountFromPacket(BowlerPacket * Packet) {
    Packet->use.head.Method = BOWLER_POST;
    Packet->use.data[0] = 0;
    Packet->use.data[1] = 0;
    Packet->use.data[2] = 0;
    Packet->use.data[3] = GetNumberOfIOChannels();
    Packet->use.head.RPC= GetRPCValue("gchc");
    Packet->use.head.DataLegnth = 4 + 4;
    FixPacket(Packet);
    return true;
}
コード例 #8
0
void POWER(BowlerPacket * packet){

	UINT16_UNION raw;
	packet->use.head.Method=BOWLER_GET;
	packet->use.head.RPC=GetRPCValue("_pwr");
	packet->use.data[0]=0;
	packet->use.data[1]=0;
	raw.Val=6500;// set rail voltage to nominal 6 volt rail for servos
	packet->use.data[2]=raw.byte.SB;
	packet->use.data[3]=raw.byte.LB;
	packet->use.data[4]=0;// Disable the brownout shutoffs and power lockouts
	packet->use.head.DataLegnth=4+2+2+1;
}
コード例 #9
0
boolean GetAllChannelModeFromPacket(BowlerPacket * Packet) {
    int i;
    Packet->use.head.Method = BOWLER_POST;
    Packet->use.head.RPC=GetRPCValue("gacm");
    Packet->use.data[0] = GetNumberOfIOChannels();
    for (i = 0; i < GetNumberOfIOChannels(); i++) {
        Packet->use.data[1 + i] = GetChannelMode(i);
    }
    Packet->use.head.DataLegnth = 4 + GetNumberOfIOChannels()+1;
    FixPacket(Packet);
    //printBowlerPacketDEBUG(Packet,WARN_PRINT);
    return true;
}
コード例 #10
0
uint8_t SetCoProConfiguration(uint8_t pin, int32_t mode) {
	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.Method = BOWLER_CRIT;
	downstreamPacketTemp.use.head.RPC = GetRPCValue("cchn");
	downstreamPacketTemp.use.data[0] = pin;
	downstreamPacketTemp.use.data[1] = true;
	downstreamPacketTemp.use.data[2] = 1;
	set32bit(&downstreamPacketTemp, mode, 3);

	downstreamPacketTemp.use.head.DataLegnth = 4 + 3 + 4;
	SendPacketToCoProc(&downstreamPacketTemp);

	return false;
}
コード例 #11
0
void DownstreamSerialStreamSet(BYTE_FIFO_STORAGE * txBuffer) {
	SetColor(0, 1, 0);
	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.RPC = GetRPCValue("strm");
	downstreamPacketTemp.use.head.MessageID = 3;
	downstreamPacketTemp.use.head.Method = BOWLER_POST;
	downstreamPacketTemp.use.data[0] = 16; //the serial rx pin
	downstreamPacketTemp.use.data[1] = FifoGetByteCount(txBuffer);
	FifoGetByteStream(txBuffer, &downstreamPacketTemp.use.data[2],
			downstreamPacketTemp.use.data[1]);
	downstreamPacketTemp.use.head.DataLegnth = 4 + 1 + 1
			+ downstreamPacketTemp.use.data[1];
	SendPacketToCoProc(&downstreamPacketTemp);
}
コード例 #12
0
void pushBufferEmpty(){
    	LoadCorePacket(& packetTemp);
	packetTemp.use.head.Method=BOWLER_ASYN;
	packetTemp.use.head.MessageID = 1;
	packetTemp.use.head.RPC = GetRPCValue("_sli");
	INT32_UNION tmp;
        tmp.Val=lastPushedBufferSize;
        packetTemp.use.data[0]=tmp.byte.FB;
        packetTemp.use.data[1]=tmp.byte.TB;
        packetTemp.use.data[2]=tmp.byte.SB;
        packetTemp.use.data[3]=tmp.byte.LB;
        packetTemp.use.head.DataLegnth=4+4;
        asyncCallback(&packetTemp);
}
コード例 #13
0
void GetAllModes(BowlerPacket * pack) {
//	println_I("GetAllModes");
	int total = 0;
	do {
		total++;
		if (total > 5) {
//			println_I("Failed returning");
			return;
		}
		LoadGACM(pack);
		SendPacketToCoProc(pack);
		buttonCheck(14);
	} while (pack->use.head.RPC != GetRPCValue("gacm"));
	//print_I("..done");
}
コード例 #14
0
ファイル: PPMReader.c プロジェクト: NeuronRobotics/dyio
void GetPPMDataToPacket(BowlerPacket * Packet){
	//println_I("Getting PPM values");
	int i;
	LoadCorePacket(Packet);
	Packet->use.head.Method=BOWLER_POST;
	Packet->use.head.RPC=GetRPCValue("strm");
	Packet->use.data[0]=23;
	Packet->use.data[1]=NUM_PPM_CHAN*2;
	for(i=0;i<NUM_PPM_CHAN;i++){
		Packet->use.data[2+i]=ppmData[i];
	}
	for(i=0;i<NUM_PPM_CHAN;i++){
		Packet->use.data[2+i+NUM_PPM_CHAN]=ppmLink[i];
	}
	Packet->use.head.DataLegnth=4+1+1+(NUM_PPM_CHAN*2);
	Packet->use.head.MessageID=0;
	SetCRC(Packet);
}
コード例 #15
0
void DownstreamSerialStreamGet(BYTE_FIFO_STORAGE * rxBuffer) {
	int i;
	uint8_t err;
	SetColor(0, 1, 0);
	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.RPC = GetRPCValue("strm");
	downstreamPacketTemp.use.head.MessageID = 3;
	downstreamPacketTemp.use.head.Method = BOWLER_GET;
	downstreamPacketTemp.use.data[0] = 17; //the serial rx pin
	downstreamPacketTemp.use.head.DataLegnth = 4 + 1;
	SendPacketToCoProc(&downstreamPacketTemp);

	for (i = 0; i < downstreamPacketTemp.use.data[1]; i++) {
		FifoAddByte(rxBuffer, downstreamPacketTemp.use.data[2 + i], &err);
	}
	//println_W("Syncing UART ");
	//printPacket(&downstreamPacketTemp, WARN_PRINT);
}
コード例 #16
0
void checkPositionChange(){
    int i;
    float tmp[4];
    updateCurrentPositions();

    tmp[0]=xCurrent;
    tmp[1]=yCurrent;
    tmp[2]=zCurrent;
    tmp[3] = getLinkAngle(3);
    if(     tmp[0]!=lastXYZE[0]||
            tmp[1]!=lastXYZE[1]||
            tmp[2]!=lastXYZE[2]||
            tmp[3]!=lastXYZE[3]){
        for(i=0;i<4;i++){
           lastXYZE[i] =tmp[i];
        }

//        println_I("Current Voltage of sensor");p_fl_E(getAdcVoltage(mapHeaterIndex(HEATER0_INDEX),10));
//        print_E(" Temp = ");p_fl_E(getHeaterTempreture(HEATER0_INDEX));
//        print_E(" Raw ADC = ");p_int_E(getAdcRaw(mapHeaterIndex(HEATER0_INDEX),10));

//        println_I("Current  position X=");p_fl_E(lastXYZE[0]);
//        print_E(" Y=");p_fl_E(lastXYZE[1]);
//        print_E(" Z=");p_fl_E(lastXYZE[2]);
//        print_E(" extr=");p_fl_E(lastXYZE[3]);
        INT32_UNION PID_Temp;
        LoadCorePacket(& packetTemp);
        packetTemp.use.head.DataLegnth=4;
        packetTemp.use.head.RPC = GetRPCValue("cpos");
        int i;
        for(i=0;i<4;i++){
                PID_Temp.Val=lastXYZE[i];
                packetTemp.use.data[0+(i*4)]=PID_Temp.byte.FB;
                packetTemp.use.data[1+(i*4)]=PID_Temp.byte.TB;
                packetTemp.use.data[2+(i*4)]=PID_Temp.byte.SB;
                packetTemp.use.data[3+(i*4)]=PID_Temp.byte.LB;
                packetTemp.use.head.DataLegnth+=4;
        }
        packetTemp.use.head.Method=BOWLER_ASYN;
        FixPacket(&packetTemp);
	asyncCallback(& packetTemp);
    }
}
コード例 #17
0
void SetLockCode(char * code) {
	//WORD_VAL raw;
	uint8_t i = 0;
	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.Method = BOWLER_POST;
	downstreamPacketTemp.use.head.RPC = GetRPCValue(eepd);
	downstreamPacketTemp.use.data[0] = LOCKSTART;
	downstreamPacketTemp.use.data[1] = DATASTART;
	while (code[i] != '\0') {
		downstreamPacketTemp.use.data[2 + i] = code[i];
		i++;
		buttonCheck(8);
		if (i == LOCKSIZE)
			break;
	}
	downstreamPacketTemp.use.data[2 + i] = '\0';
	downstreamPacketTemp.use.head.DataLegnth = 6 + LOCKSIZE;
	SendPacketToCoProc(&downstreamPacketTemp);
}
コード例 #18
0
void loadCurrentPosition(BowlerPacket * Packet){
        LoadCorePacket(Packet);
	Packet->use.head.Method=BOWLER_STATUS;
	Packet->use.head.MessageID = 1;
	Packet->use.head.RPC = GetRPCValue("ctps");
	INT32_UNION tmp;
        tmp.Val=lastPushedBufferSize;
        Packet->use.data[0]=tmp.byte.FB;
        Packet->use.data[1]=tmp.byte.TB;
        Packet->use.data[2]=tmp.byte.SB;
        Packet->use.data[3]=tmp.byte.LB;

        tmp.Val=SIZE_OF_PACKET_BUFFER;
        Packet->use.data[4]=tmp.byte.FB;
        Packet->use.data[5]=tmp.byte.TB;
        Packet->use.data[6]=tmp.byte.SB;
        Packet->use.data[7]=tmp.byte.LB;

        Packet->use.head.DataLegnth=4+4+4;
}
コード例 #19
0
boolean GetLockCode(char * code) {
	//WORD_VAL raw;
	uint8_t i = 0;
	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.Method = BOWLER_GET;
	downstreamPacketTemp.use.head.RPC = GetRPCValue(eepd);
	downstreamPacketTemp.use.data[0] = LOCKSTART;
	downstreamPacketTemp.use.data[1] = DATASTART;
	downstreamPacketTemp.use.head.DataLegnth = 6;
	SendPacketToCoProc(&downstreamPacketTemp);
	while (downstreamPacketTemp.use.data[i + 2] != '\0') {
		code[i] = downstreamPacketTemp.use.data[2 + i];
		i++;
		buttonCheck(10);
		if (i == LOCKSIZE)
			break;
	}
	code[i] = '\0';
	return isAscii(code);
}
コード例 #20
0
void SetEEPRomData(uint8_t start, uint8_t stop, uint8_t * data) {
	//println_W("Setting eeprom page: ");p_int_W(start+DATASTART);print_W(" to ");p_int_W(stop+DATASTART);
	//WORD_VAL raw;
	uint8_t i = 0;
	if (start >= stop)
		return;
	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.Method = BOWLER_POST;
	downstreamPacketTemp.use.head.RPC = GetRPCValue(eepd);
	downstreamPacketTemp.use.data[0] = start + DATASTART;
	downstreamPacketTemp.use.data[1] = stop + DATASTART;
	downstreamPacketTemp.use.data[2] = (stop - start);
	for (i = 0; i < (stop - start); i++) {
		downstreamPacketTemp.use.data[3 + i] = data[i];
	}

	downstreamPacketTemp.use.head.DataLegnth = 6 + stop - start + 1;
	//printBowlerPacketDEBUG(&downstreamPacketTemp,WARN_PRINT);
	SendPacketToCoProc(&downstreamPacketTemp);
}
コード例 #21
0
boolean ConfigureChannelFromPacket(BowlerPacket * Packet) {
    uint8_t pin = Packet->use.data[0];
    boolean setValues = Packet->use.data[1];
    uint8_t mode = GetChannelMode(pin);

    int32_t tmp;
    if(mode != 0xff && setValues){
		if (configChannelHWPtr != NULL) {

//			println_E("Pushing configs from packet ");
//			p_int_E(pin);

			tmp = get32bit(Packet,  3);

//			print_E(" value = ");
//			p_int_E(tmp);

			//println_E(__FILE__);println_E("ConfigureChannelFromPacket");
			setDataTableCurrentValue(pin,tmp);

			configChannelHWPtr(pin, 1, &tmp);
		} else {
			return false;
		}

    }
    //println_E("Loading configs into packet");
    Packet->use.head.RPC= GetRPCValue("cchn");
    Packet->use.head.Method = BOWLER_CRIT;
    Packet->use.head.DataLegnth = 4+1+(GetNumberOfIOChannels()*4);
    int32_t * data = (int32_t *) (Packet->use.data + 1);
    configChannelHWPtr(0xff, GetNumberOfIOChannels(), data);
    Packet->use.data[0] =GetNumberOfIOChannels();
    int i;
    for (i = 0; i < GetNumberOfIOChannels(); i++) {
		tmp = data[i];
		set32bit(Packet, tmp, (i*4)+1);
	}
    FixPacket(Packet);
    return true;
}
コード例 #22
0
uint8_t SetAllCoProcValues() {
	int i = 0;
	boolean send = true;
	int32_t tmp;
	if (send) {
		LoadCorePacket(&downstreamPacketTemp);
		downstreamPacketTemp.use.head.Method = BOWLER_POST;
		downstreamPacketTemp.use.head.RPC = GetRPCValue("sacv");
		set32bit(&downstreamPacketTemp, 0, 0);   // setting the translation time
		downstreamPacketTemp.use.data[4] = GetNumberOfIOChannels();
		for (i = 0; i < GetNumberOfIOChannels(); i++) {
			tmp = getBcsIoDataTable(i)->PIN.currentValue;
			down[i].changeValue = false;
			set32bit(&downstreamPacketTemp, tmp, (i * 4) + 5);
		}

		downstreamPacketTemp.use.head.DataLegnth = 4 + 4 + 1
				+ (4 * GetNumberOfIOChannels());
		SendPacketToCoProc(&downstreamPacketTemp);
	}

	for (i = 0; i < GetNumberOfIOChannels(); i++) {
		int index = (i * 4) + 1;
		if (isOutputMode(GetChannelMode(i)) == false) {
            tmp= get32bit(&downstreamPacketTemp, index);
			boolean back = (tmp != getBcsIoDataTable(i)->PIN.currentValue);

			setDataTableCurrentValue(i,tmp);
			if (back) {
				getBcsIoDataTable(i)->PIN.asyncDataenabled = true;
			}
		}
		if (GetChannelMode(i) == IS_SERVO) {
			SetServoPos(i, get32bit(&downstreamPacketTemp, index) & 0x000000ff);
		}
		if (GetChannelMode(i) == IS_UART_RX) {

		}
	}
	return true;
}
コード例 #23
0
void SetName(char * name) {
	//WORD_VAL raw;
	uint8_t i = 0;
	println_E(name);
	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.Method = BOWLER_POST;
	downstreamPacketTemp.use.head.RPC = GetRPCValue(eepd);
	downstreamPacketTemp.use.data[0] = NAMESTART;
	downstreamPacketTemp.use.data[1] = LOCKSTART;
	while (name[i] != '\0') {
		downstreamPacketTemp.use.data[2 + i] = name[i];
		i++;
		buttonCheck(9);
		if (i == NAMESIZE)
			break;
	}
	downstreamPacketTemp.use.data[2 + i] = '\0';
	downstreamPacketTemp.use.head.DataLegnth = 6 + i + 1;
	printPacket(&downstreamPacketTemp,ERROR_PRINT);
	SendPacketToCoProc(&downstreamPacketTemp);
}
コード例 #24
0
uint8_t GetCoProConfigurations() {

	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.Method = BOWLER_CRIT;
	downstreamPacketTemp.use.head.RPC = GetRPCValue("cchn");
	downstreamPacketTemp.use.data[0] = 0xff;
	downstreamPacketTemp.use.data[1] = false;
	downstreamPacketTemp.use.data[2] = 1;
	set32bit(&downstreamPacketTemp, 0, 3);

	downstreamPacketTemp.use.head.DataLegnth = 4 + 3 + 4;
	SendPacketToCoProc(&downstreamPacketTemp);
	int i;
	for (i = 0; i < GetNumberOfIOChannels(); i++) {
		down[i].currentConfiguration = get32bit(&downstreamPacketTemp,
				1 + (i * 4));
		//println_E(__FILE__);println_E("GetCoProConfigurations");
		//setDataTableCurrentValue(i,down[i].currentConfiguration);
	}

	return false;
}
コード例 #25
0
void _SetChannelValueCoProc(uint8_t PIN, uint8_t state) {
	uint8_t retry = 0;
	do {
		if (retry > 0) {
			//println_E("#*#*SetChannelValueCoProc did not return RDY pin: ");p_int_E(PIN);print_E(" mode: ");printMode(GetChannelMode(PIN),ERROR_PRINT);
			//printPacket(&downstreamPacketTemp,ERROR_PRINT);
			return;
		}
		LoadCorePacket(&downstreamPacketTemp);
		downstreamPacketTemp.use.head.Method = BOWLER_POST;
		downstreamPacketTemp.use.head.RPC = GetRPCValue("schv");
		downstreamPacketTemp.use.data[0] = PIN;
		set32bit(&downstreamPacketTemp, state, 1);
		set32bit(&downstreamPacketTemp, 0, 5);			// zero ms
		downstreamPacketTemp.use.head.DataLegnth = 4 + 1 + 4 + 4;
		SendPacketToCoProc(&downstreamPacketTemp);
		setDataTableCurrentValue(PIN, state);
		retry++;
		buttonCheck(13);
	} while (downstreamPacketTemp.use.head.RPC != _RDY);

}
コード例 #26
0
uint8_t SetAllCoProcMode() {
	int i = 0;
	boolean send = false;
	for (i = 0; i < GetNumberOfIOChannels(); i++) {
		if (down[i].changeMode == true) {
			send = true;
		}
	}
	if (send) {

		LoadCorePacket(&downstreamPacketTemp);
		downstreamPacketTemp.use.head.Method = BOWLER_POST;
		downstreamPacketTemp.use.head.RPC = GetRPCValue("sacm");
		downstreamPacketTemp.use.data[0] = GetNumberOfIOChannels();
		for (i = 0; i < GetNumberOfIOChannels(); i++) {
			downstreamPacketTemp.use.data[i + 1] =GetChannelMode(i) ;
			down[i].changeMode = false;
		}
		downstreamPacketTemp.use.head.DataLegnth = 4 + 1+ GetNumberOfIOChannels();
        //println_I("Sending mode sync packet");printPacket(&downstreamPacketTemp,WARN_PRINT);
		SendPacketToCoProc(&downstreamPacketTemp);
//		for (i = 0; i < NUM_PINS; i++) {
//			if (downstreamPacketTemp.use.data[i + 1] == NO_CHANGE) {
//				//getBcsIoDataTable(i)->PIN.currentChannelMode = IS_DI;
//				SetChannelModeDataTable(i,IS_DI);
//				down[i].changeMode = true;	// force a sync of the no valid mode
//				//println_E("FAULT: the mode was set to NO_CHANGE");
//			} else {
//				//getBcsIoDataTable(i)->PIN.currentChannelMode =downstreamPacketTemp.use.data[i + 1];
//				SetChannelModeDataTable(i,downstreamPacketTemp.use.data[i + 1]);
//				down[i].changeMode = false;
//			}
//		}

	}
	return true;
}
コード例 #27
0
boolean GetName(char * name) {
	//WORD_VAL raw;
	uint8_t i = 0;
	LoadCorePacket(&downstreamPacketTemp);
	downstreamPacketTemp.use.head.Method = BOWLER_GET;
	downstreamPacketTemp.use.head.RPC = GetRPCValue(eepd);
	downstreamPacketTemp.use.data[0] = NAMESTART;
	downstreamPacketTemp.use.data[1] = LOCKSTART;
	downstreamPacketTemp.use.head.DataLegnth = 6;
	SendPacketToCoProc(&downstreamPacketTemp);

	printPacket(&downstreamPacketTemp,WARN_PRINT);

	while (downstreamPacketTemp.use.data[i] != '\0') {
		name[i] = downstreamPacketTemp.use.data[i];
		i++;
		buttonCheck(11);
		if (i == NAMESIZE)
			break;
	}
	name[i] = '\0';
	println_W(name);
	return isAscii(name);
}
コード例 #28
0
void ProcessAsyncData(BowlerPacket * Packet){
	//println_I("**Got Async Packet**");
	//printPacket(Packet,INFO_PRINT);

	Print_Level l = getPrintLevel();
	setPrintLevelInfoPrint();

	if (Packet->use.head.RPC==GCHV){
		BYTE pin = Packet->use.data[0];
		BYTE mode = GetChannelMode(pin);
		if(mode == IS_ANALOG_IN ){
			UINT16_UNION ana;
			ana.byte.SB = Packet->use.data[1];
			ana.byte.LB = Packet->use.data[2];
			//ADC_val[pin-8]=ana.Val;
			if(ana.Val>=0 && ana.Val<1024)
				SetValFromAsync(pin,ana.Val);//asyncData[pin].currentVal=ana.Val;
			println_I("***Setting analog value: ");p_int_I(pin);print_I(", ");p_int_I(ana.Val);
		}
		else if((mode == IS_DI) || (mode == IS_COUNTER_INPUT_HOME)|| (mode == IS_COUNTER_OUTPUT_HOME) || mode == IS_SERVO){
			//DIG_val[pin]=Packet->use.data[1];
			SetValFromAsync(pin,Packet->use.data[1]);//asyncData[pin].currentVal=Packet->use.data[1];
			println_I("***Setting digital value: ");p_int_I(pin);print_I(", ");p_int_I(Packet->use.data[1]);//printStream(DIG_val,NUM_PINS);
		}else {
			if(IsAsync(pin)){
				println_I("Sending async packet, not digital or analog");
				PutBowlerPacket(Packet);
			}
		}
	}else if (Packet->use.head.RPC==AASN){
		int i;
		for(i=0;i<8;i++){
			BYTE pin = i+8;
			BYTE mode = GetChannelMode(pin);
			if(mode == IS_ANALOG_IN ){
				UINT16_UNION ana;
				ana.byte.SB = Packet->use.data[i*2];
				ana.byte.LB = Packet->use.data[(i*2)+1];
				//ADC_val[pin-8]=ana.Val
				if(ana.Val>=0 && ana.Val<1024);
					SetValFromAsync(pin,ana.Val);//asyncData[pin].currentVal=ana.Val;
			}
		}
	}else if (Packet->use.head.RPC==DASN){
		int i;
		for(i=0;i<GetNumberOfIOChannels();i++){
			BYTE mode = GetChannelMode(i);
			if((mode == IS_DI) || (mode == IS_COUNTER_INPUT_HOME)|| (mode == IS_COUNTER_OUTPUT_HOME)|| (mode == IS_SERVO)){
				SetValFromAsync(i,Packet->use.data[i]);//asyncData[i].currentVal=Packet->use.data[i];
			}

		}
		//println_I("***Setting All Digital value: ");
	}if (Packet->use.head.RPC==GetRPCValue("gacv")){
		int i;
		int val;
		for(i=0;i<GetNumberOfIOChannels();i++){
			val = get32bit(Packet, i*4);
			if(getBcsIoDataTable()[i].PIN.asyncDataCurrentVal!=val){
				println_I("Data on Pin ");p_int_I(i);print_I(" to val ");p_int_I(val);
				SetValFromAsync(i,val);//
			}
		}
	}else{
		println_W("***Async packet not UNKNOWN***");
		printPacket(Packet,WARN_PRINT);
	}
//	println_I("***Setting All value: [");
//	int i;
//	for(i=0;i<NUM_PINS;i++){
//		p_int_I(asyncData[i].currentVal);print_I(" ");
//	}
//	print_I("]");
	setPrintLevel(l);
}
コード例 #29
0
void advancedBowlerExample() {
    /**
     * User code must implement a few functions needed by the stack internally
     * This Platform specific code can be stored in the Platform directory if it is universal for all
     * implementations on the given Platform.
     * float getMs(void) Returns the current milliseconds since the application started
     * StartCritical()   Starts a critical protected section of code
     * EndCritical()     Ends the critical section and returns to normal operation
     */
    setPrintLevelInfoPrint();// enable the stack specific printer. If you wish to use this feature putCharDebug(char c) needs to be defined
    printf("\r\nStarting Sample Program\r\n");
    int pngtmp = GetRPCValue("_png");
    if(pngtmp != _PNG) {
        printf("\r\nFAIL Expected: ");
        prHEX32(_PNG,INFO_PRINT);
        printf(" got: ");
        prHEX32(pngtmp,INFO_PRINT);
        return;
    }

    /**
     * First we are going to put together dummy array of packet data. These are examples of a _png receive and a custom response.
     * These would not exist in your implementation but would come in from the physical layer
     */
    BowlerPacket myPngPacket;
    myPngPacket.use.head.RPC = GetRPCValue("apid");
    myPngPacket.use.head.MessageID = 2;// Specify namespace 2 for the collision detect
    myPngPacket.use.head.Method = BOWLER_GET;
    myPngPacket.use.head.DataLegnth=4;
    FixPacket(&myPngPacket);// Set up the stack content

    BowlerPacket myNamespacTestPacket;
    myNamespacTestPacket.use.head.RPC = GetRPCValue("rtst");
    myNamespacTestPacket.use.head.Method = BOWLER_GET;
    myNamespacTestPacket.use.data[0] = 37;
    myNamespacTestPacket.use.head.DataLegnth=4+1;
    FixPacket(&myNamespacTestPacket);// Set up the stack content


    /**
     * Now we begin to set up the stack features. The first step is to set up the FIFO to receive the data coming in asynchronously
     *
     */
    BYTE privateRXCom[sizeof(BowlerPacket)];//make the buffer at least big enough to hold one full sized packet
    BYTE_FIFO_STORAGE store;//this is the FIFO data storage struct. All interactions with the circular buffer will go through this.
    /**
     * Next we initialize the buffer
     */
    InitByteFifo(&store,// the pointer to the storage struct
                 privateRXCom,//pointer the the buffer
                 sizeof(privateRXCom));//the size of the buffer

    Bowler_Init();// Start the Bowler stack

    /**
     * Now we are going to regester what namespaces we implement with the framework
     */
    NAMESPACE_LIST * tmp =getBcsPidNamespace();
    addNamespaceToList(tmp);
    tmp = getBcsTestNamespace();
    addNamespaceToList(tmp);


    printf("\r\n# of namespaces declared= %i",getNumberOfNamespaces());
    int i=0;
    for(i=0; i<getNumberOfNamespaces(); i++) {
        NAMESPACE_LIST * nsPtr = getNamespaceAtIndex(i);
        printf("\r\nNamespace %s at index %i",nsPtr->namespaceString,i);
    }

    /**
     * Now we load the buffer with the the packet that we "Received"
     * This step would come in from the physical layer, usually on
     * an interrupt on a mcu.
     */

    for (i=0; i<GetPacketLegnth(&myPngPacket); i++) {
        BYTE err;// this is a stack error storage byte. See Bowler/FIFO.h for response codes
        BYTE b= myPngPacket.stream[i];// This would be a new byte from the physical layer
        FifoAddByte(&store, b, &err);// This helper function adds the byte to the storage buffer and manages the read write pointers.
    }
    /**
     * Next we load the new namespace packet
     */
    i=0;
    for (i=0; i<GetPacketLegnth(&myNamespacTestPacket); i++) {
        BYTE err;// this is a stack error storage byte. See Bowler/FIFO.h for response codes
        BYTE b= myNamespacTestPacket.stream[i];// This would be a new byte from the physical layer
        FifoAddByte(&store, b, &err);// This helper function adds the byte to the storage buffer and manages the read write pointers.
    }

    printf("\r\nData loaded into packet\r\n");
    /**
     * We have now loaded a packet into the storage struct 'store'
     * All the while we can be polling the storage struct for a new packet
     */
    BowlerPacket myLocalPacket; // Declare a packet struct to catch the parsed packet from the asynchronous storage buffer
    while(getNumBytes(&store)>0) {
        while(Bowler_Server_Static(&myLocalPacket,// pointer to the local packet into which to store the parsed packet
                                   &store// storage struct from which the packet will be checked and parsed.
                                  ) == FALSE) { // Returns true when a packet is found and pulled out of the buffer
            // wait because there is no packet yet
        }

        /**
         * At this point the packet has been parsed and pulled out of the buffer
         * The Static server will have also called the call backs to pars the packet, so
         * the response should be loaded up to send back
         */

        int packetLength = GetPacketLegnth(&myLocalPacket); // helper function to get packet length

        printf("\r\nPreparing to send:\r\n");
        printPacket(&myLocalPacket, INFO_PRINT);

        printf("\r\nSending Packet Data back out: [ ");
        for(i=0; i< packetLength; i++) {
            //This would be sending to the physical layer. For this example we are just printing out the data
            printf(" %i ",myLocalPacket.stream[i]);
        }
        printf(" ] \r\n");
    }
}
コード例 #30
0
ファイル: UpstreamPackets.c プロジェクト: NeuronRobotics/dyio
//			set32bit(&packetTemp, get32bit(&packetTemp, packetIndex)&0x000000ff, packetIndex);
//		}
//	}
//
//	packetTemp.use.head.Method=BOWLER_ASYN;
//	Print_Level l = getPrintLevel();
//	setPrintLevelInfoPrint();
//	PutBowlerPacket(& packetTemp);
//	println_W("Sending All Async: ");printPacket(&packetTemp,WARN_PRINT);
//	setPrintLevel(l);
//}


void UpstreamPushPowerChange(uint8_t r0,uint8_t r1, uint16_t voltage, uint8_t override){
	SetColor(0,1,0);
	packetTemp.use.head.RPC=GetRPCValue("_pwr");
	packetTemp.use.head.MessageID=3;
	packetTemp.use.head.Method=BOWLER_ASYN;
	packetTemp.use.data[0]=r0;
	packetTemp.use.data[1]=r1;
	set16bit(&packetTemp,voltage,2);
	packetTemp.use.data[4]=override;
	packetTemp.use.head.DataLegnth=4+2+2+1;

	PutBowlerPacketLocal(& packetTemp);
	printPacket(&packetTemp,WARN_PRINT);
}

void UpstreamPushSPIlStream(void){
	SetColor(0,1,0);
	LoadCorePacket(& packetTemp);