Ejemplo n.º 1
0
//------------------------------------------------------------------------------
u08 AVCLan_SendAnswer()
{
 u08 r = 0 ;
 
 switch (answerReq) {
 	case cmStatus1:		r = AVCLan_SendAnswerFrame((u08*)CMD_STATUS1); 
						break;
 	case cmStatus2:		r = AVCLan_SendAnswerFrame((u08*)CMD_STATUS2); 
						break;
 	case cmStatus3:		r = AVCLan_SendAnswerFrame((u08*)CMD_STATUS3); 
						break;
 	case cmStatus4:		r = AVCLan_SendAnswerFrame((u08*)CMD_STATUS4); 
						break;
 	case cmRegister:	r = AVCLan_SendAnswerFrame((u08*)CMD_REGISTER); 
						break;
 	case cmInit:		//RS232_Print("INIT\n");
						r = AVCLan_SendInitCommands(); 
						break;
 	case cmCheck:		r = AVCLan_SendAnswerFrame((u08*)CMD_CHECK); 
						check_timeout = 0;
						CMD_CHECK[6]++;
 						RS232_Print("AVCCHK\n");
						break;
 	case cmPlayReq1:	playMode = 0;
						r = AVCLan_SendAnswerFrame((u08*)CMD_PLAY_OK1); 
						break;
 	case cmPlayReq2:	
	case cmPlayReq3:	playMode = 0;
						r = AVCLan_SendAnswerFrame((u08*)CMD_PLAY_OK2); 
						if (!r) r = AVCLan_SendAnswerFrame((u08*)CMD_PLAY_OK3);
						CD_Mode = stPlay;
						break;
	case cmPlayIt:		playMode = 1;
						RS232_Print("PLAY\n");
						CMD_PLAY_OK4[7]=cd_Disc;
						CMD_PLAY_OK4[8]=cd_Track;
						CMD_PLAY_OK4[9]=cd_Time_Min;
						CMD_PLAY_OK4[10]=cd_Time_Sec;
						r = AVCLan_SendAnswerFrame((u08*)CMD_PLAY_OK4); 
						if (!r) AVCLan_Send_Status();
						CD_Mode = stPlay;
						break;
	case cmStopReq:
	case cmStopReq2:	CD_Mode = stStop;
						playMode = 0;
						
						r = AVCLan_SendAnswerFrame((u08*)CMD_STOP1); 
						CMD_STOP2[7]=cd_Disc;
						CMD_STOP2[8]=cd_Track;
						CMD_STOP2[9]=cd_Time_Min;
						CMD_STOP2[10]=cd_Time_Sec;
						r = AVCLan_SendAnswerFrame((u08*)CMD_STOP2); 
						break;
	case cmBeep:		AVCLan_SendAnswerFrame((u08*)CMD_BEEP);
						break;
 }

 answerReq = cmNull;
 return r;
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
int main()
{
 PIN_Setup();
 
 //delay_ms(100);

 AVCLan_Init();

 #ifndef SNIFFER
 	iPod_Init();
 #endif

#ifdef MONITOR
	RS232_Print("********************** RESET *********************\n");
 #endif

 while (1) {

	if (INPUT_IS_SET) {	 // if message from some device on AVCLan begin
  		AVCLan_Read_Message();
		// check command from HU
		if (answerReq != 0) AVCLan_SendAnswer();
	}

	#ifndef SNIFFER
	// HandleEvent
	if (Event & EV_STATUS)
		{
		Event &= ~EV_STATUS;
	  	if (CD_Mode!=stStop) {
			AVCLan_Send_Status();
			};
		}

	if (Event & EV_DISPLAY)
		{
		Event &= ~EV_DISPLAY;
		AVCLan_Send_Changer_Status();
		}
	#endif

	RS232_SendStuff();
 } // end while(1)
}
Ejemplo n.º 3
0
// -------------------------------------------------------------------------------------
//	MAIN PROGRAM
//
int main()
{

 u08 readSeq 	= 0;
 u08 s_len	= 0;
 u08 s_dig	= 0;
 u08 s_c[2];
 u08 i;
 u08 data_tmp[32];

 Setup();
 
 RS232_S((u16)PSTR("AVCLan reader 1.00\nReady\n\n"));
 LED_OFF();
 RS232_S((u16)PSTR("T - device id\n"));
 RS232_S((u16)PSTR("H - HU id\n"));
 RS232_S((u16)PSTR("S - read sequence\n"));
 RS232_S((u16)PSTR("W - send command\n"));
 RS232_S((u16)PSTR("Q - send broadcast\n"));
 RS232_S((u16)PSTR("L/l - log on/off\n"));
 RS232_S((u16)PSTR("K/k - seq. echo on/off\n"));
 RS232_S((u16)PSTR("R/r - register device\n"));
 
 while (1) {

	if (INPUT_IS_SET) {	 // if message from some device on AVCLan begin
		//LED_ON();
  		AVCLan_Read_Message();
		// show message
	} else {
		//LED_OFF();
		// check command from HU
		if (answerReq != 0) AVCLan_SendAnswer();
	}

	// HandleEvent
	switch (Event) {
	  case EV_STATUS:	Event &= ~EV_STATUS;
						AVCLan_Send_Status();
						break;
	}


	// Key handler
	if (RS232_RxCharEnd) {
		cbi(UCSR0B, RXCIE0);				// disable RX complete interrupt
		readkey = RS232_RxCharBuffer[RS232_RxCharBegin];// read begin of received Buffer
		RS232_RxCharBegin++;
		if (RS232_RxCharBegin == RS232_RxCharEnd)	// if Buffer is empty
			RS232_RxCharBegin = RS232_RxCharEnd = 0;// do reset Buffer
		sbi(UCSR0B, RXCIE0);				// enable RX complete interrupt
		switch (readkey) {
			case 'T':	if (readSeq) {
						  CD_ID_1 = data_tmp[0];
						  CD_ID_2 = data_tmp[1];
						  RS232_Print("DEV ID SET: 0x");
						  RS232_PrintHex8(CD_ID_1);
						  RS232_PrintHex8(CD_ID_2);
						  RS232_Print("\n");
						  showLog = 1;	
						  readSeq=0;
						} else {
						  showLog = 0;
						  RS232_Print("DEV ID SET: 0x");
						  RS232_PrintHex8(CD_ID_1);
						  RS232_PrintHex8(CD_ID_2);
						  RS232_Print("\n");
						  RS232_Print("DEV ID > \n");
						  readSeq = 1;
						  s_len=0;
						  s_dig=0;
						  s_c[0]=s_c[1]=0;
						}
						break;

			case 'H':	if (readSeq) {
						  HU_ID_1 = data_tmp[0];
						  HU_ID_2 = data_tmp[1];
						  RS232_Print("HU ID SET: 0x");
						  RS232_PrintHex8(HU_ID_1);
						  RS232_PrintHex8(HU_ID_2);
						  RS232_Print("\n");
						  showLog = 1;	
						  readSeq=0;
						} else {
						  showLog = 0;
						  RS232_Print("HU ID SET: 0x");
						  RS232_PrintHex8(HU_ID_1);
						  RS232_PrintHex8(HU_ID_2);
						  RS232_Print("\n");
						  RS232_Print("HU ID > \n");
						  readSeq = 1;
						  s_len=0;
						  s_dig=0;
						  s_c[0]=s_c[1]=0;
						}
						break;

			case 'S':	showLog = 0;
						RS232_Print("READ SEQUENCE > \n");
						readSeq = 1;
						s_len=0;
						s_dig=0;
						s_c[0]=s_c[1]=0;
						break;
			case 'W' :  showLog = 1;
						readSeq=0;
						AVCLan_SendMyData(data_tmp, s_len);
						break;
			case 'Q' :  showLog = 1;
						readSeq=0;
						AVCLan_SendMyDataBroadcast(data_tmp, s_len);
						break;


			case 'R':	RS232_Print("REGIST:\n");
						AVCLan_Command( cmRegister );
 						_delay_us(15);
 						CHECK_AVC_LINE;
						break;
			case 'r':	AVCLan_Register();
						break;


			case 'l':	RS232_Print("Log OFF\n");
						showLog = 0;
						break;
			case 'L':	RS232_Print("Log ON\n");
						showLog = 1;
						break;

			case 'k':	RS232_Print("str OFF\n");
						showLog2 = 0;
						break;
			case 'K':	RS232_Print("str ON\n");
						showLog2 = 1;
						break;

			default :
				if (readSeq==1) {
					s_c[s_dig]=readkey;
				
					s_dig++;
					if (s_dig==2) {
						if (s_c[0]<':') s_c[0] -= 48;
								   else s_c[0] -= 55;
						data_tmp[s_len] = 16 * s_c[0];
						if (s_c[1]<':') s_c[1] -= 48;
								   else s_c[1] -= 55;
						data_tmp[s_len] += s_c[1];
						s_len++;
						s_dig=0;
						s_c[0]=s_c[1]=0;
					}
					if (showLog2) {
						RS232_Print("CURREENT SEQUENCE > ");
						for (i=0; i<s_len; i++) {
								RS232_PrintHex8(data_tmp[i]);
								RS232_SendByte(' ');
						}
						RS232_Print("\n");
					}
				}
		} // switch (readkey)

	}// if (RS232_RxCharEnd)

 }
 return 0;
}
Ejemplo n.º 4
0
//------------------------------------------------------------------------------
int main()
{

 PIN_Setup();

 AVCLan_Init();

 iPod_Init();


#ifdef MONITOR
	delay_ms(100);
	 RS232_Print("********************** RESET *********************8\n");
 #endif

 while (1) {

	//Wait1msForAVCLan();
	if ((INPUT_IS_SET>0) & (ACC_IS_ON>0)) {	 // if message from some device on AVCLan begin
  		AVCLan_Read_Message();
	} else {
		// check command from HU
		if ((answerReq != 0) & (RXState == WAITING_FOR_FF)) AVCLan_SendAnswer();
	
    }

	// HandleEvent
	if (((Event & EV_STATUS)>0) & (RXState == WAITING_FOR_FF)) {
	  	if (CD_Mode != stStop) {
			if ((CD_Mode == stFF) | (CD_Mode == stRR)) {
				if (!AVCLan_Send_Status(0x18)) Event &= ~EV_STATUS;
				}
			else
				{
			    switch (playMode) {
					case 0: if (!AVCLan_Send_Status(0x03)) Event &= ~EV_STATUS; break;
					case 1:	if (!AVCLan_Send_Status(0x10)) Event &= ~EV_STATUS; break;
				};
			};
		};
    }

	if (Event & EV_DISPLAY)	{
		if (!AVCLan_Send_Changer_Status()) Event &= ~EV_DISPLAY;;
	};

	if (ACC_IS_ON) 	{
		// audio output
		if (CD_Mode == stStop)
			CHANNELS_OFF();

		if (CD_Mode == stPlay)
			{
			if (AuxInput==Aux2)
				CHANNEL_TWO();
			if (AuxInput==Aux1)
				CHANNEL_ONE();
			}
		}	else 	{ 
			CHANNELS_OFF();
			CD_Mode = stStop;
			playMode = 0;
		};

	// iPod
	if (AUX1ISIPOD)
		iPod_Poll();
	
	if (!(ACC_IS_ON))
		registered = 0;
	// zzzzz
	//if (sleepcounter > 5)
	//	{ 
	//	CHANNELS_OFF();
	//	sleep_mode();
	//	sleepcounter = 0;
	//	}
 } // end while(1)
}