static int vti_get(CableHandle *h, uint8_t *data, uint32_t len)
{
	unsigned int i;
	tiTIME clk;

	if(!hMap) return 0;
	if(vRecvBuf)
	{
		/* Wait that the buffer has been filled */
		for(i = 0; i < len; i++)
		{
			TO_START(clk);
			do
			{
				if (TO_ELAPSED(clk, h->timeout))
					return ERR_READ_TIMEOUT;
			}
			while (vRecvBuf->start == vRecvBuf->end);

			/* And retrieve the data from the circular buffer */
			data[i] = vRecvBuf->buf[vRecvBuf->start];
			vRecvBuf->start = (vRecvBuf->start + 1) & (BUFSIZE-1);
		}
	}
	else
	{
		ticables_critical("vti_get(): receive buffer busted !\n");
	}

	return 0;
}
static int vti_put(CableHandle *h, uint8_t *data, uint32_t len)
{
	unsigned int i;
	tiTIME clk;

	if(!hMap) return 0;
	if(vSendBuf)
	{
		for(i = 0; i < len; i++)
		{
			TO_START(clk);
			do
			{
				if (TO_ELAPSED(clk, h->timeout))
					return ERR_WRITE_TIMEOUT;
			}
			while (((vSendBuf->end + 1) & (BUFSIZE-1)) == vSendBuf->start);

			vSendBuf->buf[vSendBuf->end] = data[i];
			vSendBuf->end = (vSendBuf->end + 1) & (BUFSIZE-1);
		}
	}
	else
	{
		ticables_critical("vti_put(): send buffer busted !\n");
	}

	return 0;
}
Exemple #3
0
static int vti_put(CableHandle *h, uint8_t *data, uint32_t len)
{
    int p = h->address;
    uint32_t i;
    tiTIME clk;
    
    for(i = 0; i < len; i++)
    {
	TO_START(clk);
	do 
	{
	    if (TO_ELAPSED(clk, h->timeout))
		return ERR_WRITE_TIMEOUT;
	}
	while (((send_buf[p]->end + 1) & 255) == send_buf[p]->start);
	
	send_buf[p]->buf[send_buf[p]->end] = data[i];
	send_buf[p]->end = (send_buf[p]->end + 1) & 255;
    }
    
    return 0;
}
Exemple #4
0
static int vti_get(CableHandle *h, uint8_t *data, uint32_t len)
{
    int p = h->address;
    uint32_t i;
    tiTIME clk;
    
    for(i = 0; i < len; i++)
    {
	TO_START(clk);
	do 
	{
	    if (TO_ELAPSED(clk, h->timeout))
		return ERR_READ_TIMEOUT;
	}
	while (recv_buf[p]->start == recv_buf[p]->end);
	
	
	data[i] = recv_buf[p]->buf[recv_buf[p]->start];
	recv_buf[p]->start = (recv_buf[p]->start + 1) & 255;
    }
    
    return 0;
}