예제 #1
0
/* init the parameters */
static void zsend_init(void)
{
	rt_err_t res = -RT_ERROR;

	zinit_parameter();
	for(;;)          /* wait ZPAD */
	{
		res = zread_line(800);
		if (res == ZPAD) break;
	}
	for (;;) 
	{
	    res = zget_header(rx_header);
		if (res == ZRINIT) break;
	}
	if ((rx_header[ZF1] & ZRQNVH))
	{
		zput_pos(0x80L);	/* Show we can var header */
		zsend_hex_header(ZRQINIT, tx_header);
	}
	Rxflags = rx_header[ZF0] & 0377;
	if (Rxflags & CANFC32) Txfcs32 = 1;    /* used 32bits CRC check */

	if (ZF2_OP == ZTRLE && (Rxflags & CANRLE))	  /* for RLE packet */
		 Txfcs32 = 2;
	else
		ZF2_OP = 0;
    /* send SINIT cmd */
	return;
}
예제 #2
0
/* receive files */
static rt_err_t zrec_files(struct zfile *zf)
{
	rt_uint8_t *rxbuf;
	rt_err_t res = -RT_ERROR;

	zinit_parameter();
	rxbuf = rt_malloc(RX_BUFFER_SIZE*sizeof(rt_uint8_t));
	if (rxbuf == RT_NULL) {
		rt_kprintf("rxbuf: out of memory\r\n");
		return -RT_ERROR;
	}
	rt_kprintf("\r\nrz: ready...\r\n");	   /* here ready to receive things */
	if ((res = zrec_init(rxbuf,zf))!= RT_EOK) {
		rt_kprintf("\b\b\breceive init failed\r\n");
		rt_free(rxbuf);
		return -RT_ERROR;
	}
	res = zrec_file(rxbuf,zf);
	if (res == ZFIN) {
		rt_free(rxbuf);
		return RT_EOK;	     /* if finish session */
	} else if (res == ZCAN) {
		rt_free(rxbuf);
		return ZCAN;        /* cancel by sender */
	} else {
		zsend_can();
		rt_free(rxbuf);
		return res;
	}
}