Ejemplo n.º 1
0
signed WaitForRestart (struct plc * plc)

{
	if (_allclr (plc->flags, PLC_QUICK_FLASH))
	{
		char firmware [PLC_VERSION_STRING];
		if (WaitForReset (plc, firmware, sizeof (firmware)))
		{
			error (PLC_EXIT (plc), 0, "Device did not Reset");
			return (-1);
		}
		if (WaitForStart (plc, firmware, sizeof (firmware)))
		{
			error (PLC_EXIT (plc), 0, "Device did not Start");
			return (-1);
		}
	}
	return (0);
}
Ejemplo n.º 2
0
signed ResetAndWait (struct int6k * int6k) 

{

	struct channel * channel = (struct channel *)(int6k->channel);
	struct message * message = (struct message *)(int6k->message);
#ifndef __GNUC__
#pragma pack (push,1)
#endif

	struct __packed vs_rs_dev_confirm 
	{
		struct header_eth ethernet;
		struct header_int intellon;
		uint8_t MSTATUS;
	}
	* confirm = (struct vs_rs_dev_confirm *) (message);

#ifndef __GNUC__
#pragma pack (pop)
#endif

	char string [INT6K_VERSTRING];
	Request (int6k, "Reset Device");
	memset (message, 0, sizeof (struct message));
	EthernetHeader (&message->ethernet, channel->peer, channel->host);
	IntellonHeader (&message->intellon, (VS_RS_DEV | MMTYPE_REQ));
	int6k->packetsize = ETHER_MIN_LEN;
	if (SendMME (int6k) <= 0) 
	{
		error ((int6k->flags & INT6K_BAILOUT), ECANCELED, INT6K_CANTSEND);
		return (-1);
	}
#if 0
	if (ReadMME (int6k, (VS_RS_DEV | MMTYPE_CNF)) <= 0) 
	{
		error ((int6k->flags & INT6K_BAILOUT), ECANCELED, INT6K_CANTREAD);
		return (-1);
	}
	if (confirm->MSTATUS) 
	{
		Failure (int6k, INT6K_WONTDOIT);
		return (-1);
	}
	Confirm (int6k, "Resetting ...");
	if (WaitForReset (int6k)) 
	{
		return (-1);
	}
	if (WaitForStart (int6k, string, sizeof (string))) 
	{
		return (-1);
	}
#else
	while (ReadMME (int6k, (VS_RS_DEV | MMTYPE_CNF)) > 0) 
	{ 
		if (confirm->MSTATUS) 
		{
			continue;
		}
		Confirm (int6k, "Start %s", string);
		return (0);
	}
#endif
	return (-1);
}
Ejemplo n.º 3
0
signed ResetAndWait (struct plc * plc)

{
	struct channel * channel = (struct channel *)(plc->channel);
	struct message * message = (struct message *)(plc->message);

#ifndef __GNUC__
#pragma pack (push,1)
#endif

	struct __packed vs_rs_dev_request
	{
		struct ethernet_hdr ethernet;
		struct qualcomm_hdr qualcomm;
		uint8_t MSTATUS;
	}
	* request = (struct vs_rs_dev_request *) (message);
	struct __packed vs_rs_dev_confirm
	{
		struct ethernet_hdr ethernet;
		struct qualcomm_hdr qualcomm;
		uint8_t MSTATUS;
		uint8_t MDEVICEID;
		uint8_t MVERLENGTH;
		char MVERSION [PLC_VERSION_STRING];
	}
	* confirm = (struct vs_rs_dev_confirm *) (message);

#ifndef __GNUC__
#pragma pack (pop)
#endif

	char firmware [PLC_VERSION_STRING];
	Request (plc, "Reset Device");
	memset (message, 0, sizeof (* message));
	EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type);
	QualcommHeader (&request->qualcomm, 0, (VS_RS_DEV | MMTYPE_REQ));
	plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
	if (SendMME (plc) <= 0)
	{
		error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
		return (-1);
	}
	memset (firmware, 0, sizeof (firmware));

#if 0

	if (ReadMME (plc, (VS_RS_DEV | MMTYPE_CNF)) <= 0)
	{
		error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD);
		return (-1);
	}
	if (confirm->MSTATUS)
	{
		Failure (plc, PLC_WONTDOIT);
		return (-1);
	}
	Confirm (plc, "Resetting ...");
	if (WaitForReset (plc))
	{
		Failure (plc, "Device did not Reset");
		return (-1);
	}
	if (WaitForStart (plc, firmware, sizeof (firmware)))
	{
		Failure (plc, "Device did not Start");
		return (-1);
	}

#else

	while (ReadMME (plc, 0, (VS_RS_DEV | MMTYPE_CNF)) > 0)
	{
		if (confirm->MSTATUS)
		{
			continue;
		}
		return (0);
	}

#endif

	return (-1);
}