Ejemplo n.º 1
0
void PushSerial(void){
	UINT16 num = Get_UART_Byte_CountPassThrough();
	//FlagBusy_IO=1;
	//_delay_us(800);
	sendHeader(4+1+num,"gchv");
	send(17);
	UINT16 i;
	BYTE b;
	for(i=0;i<num;i++){
		UARTGetArrayPassThrough(&b,1);
		send(b);
	}
	//FlagBusy_IO=0;
	//_delay_us(800);
}
Ejemplo n.º 2
0
boolean checkDigital(){
	int i;
	for(i=0;i<GetNumberOfIOChannels();i++){
		uint8_t mode = GetChannelMode(i);
		boolean run = (((mode == IS_DI) )  || ((mode == IS_COUNTER_INPUT_HOME)||(mode == IS_COUNTER_OUTPUT_HOME) || (mode == IS_SERVO)));
		if (run){
			if(mode == IS_SERVO){
				//setDataTableCurrentValue(i,GetServoPos(i));
			}else{
				if(GetValFromAsync(i) != GetDIO(i)){
					setDataTableCurrentValue(i,GetDIO(i));
					//printAsync();
				}
			}
		}
		if(mode == IS_UART_RX){
			setDataTableCurrentValue(i,Get_UART_Byte_CountPassThrough());
		}
	}
	return true; 
}
BOOL GetChannelValue(BowlerPacket * Packet){
	BOOL ret=FALSE;
	BYTE pin = Packet->use.data[0];
	BYTE mode = GetChannelMode(pin);
	//int i;
	UINT16 val=GetChanVal(pin);
	if(IsAsync(pin)){
		//AsynAck();
	}
	Packet->use.head.Method=BOWLER_POST;
	if ((mode == IS_DC_MOTOR_VEL)||(mode == IS_DC_MOTOR_DIR)||(mode == IS_DO)|| (mode == IS_PWM)|| (mode == IS_SERVO) || (mode == IS_DI) ||(mode == IS_COUNTER_OUTPUT_HOME)||(mode == IS_COUNTER_INPUT_HOME)){
		set8bit(Packet, val,1);
		Packet->use.head.DataLegnth=6;
		ret = TRUE;
	}else if ((mode == IS_ANALOG_IN)){
		val=GetADC(pin);
		set16bit(Packet,val,1);
		Packet->use.head.DataLegnth=7;
		ret = TRUE;
	}else if ( (mode == IS_UART_TX) || (mode == IS_UART_RX)){
		//Number of bytes in the stream to be sent
		Packet->use.head.DataLegnth=5;
		UINT16 numBytes=Get_UART_Byte_CountPassThrough();
		if(numBytes>0){
			UARTGetArrayPassThrough(Packet->use.data+1,numBytes);
			//Offset using pointer, rather then shuffeling
//			for (i=0;i<numBytes;i++){
//				Packet->use.data[(numBytes)-i]=Packet->use.data[(numBytes-1)-i];
//			}
			Packet->use.data[0]=17;
			Packet->use.head.DataLegnth+=numBytes;
		}
		return TRUE;
	}else{
		return FALSE;
	}
	return ret;
}