Ejemplo n.º 1
0
void WSTask(){
	int s;
	int suspended = 0;
	int counter = 0;
	long read,total;
	INT8U err;
	alt_u16 buff[BUFFER_SIZE];

	//Setup connection to server
	struct sockaddr_in result;
	memset(&result, 0, sizeof(struct sockaddr_in));
	result.sin_family = AF_INET;
	result.sin_port = htons(MY_PORT);
	net_aton("198.23.158.70", &(result.sin_addr));

	//Test the connection
	s = socket(AF_INET, SOCK_STREAM, 0);
	if (s < 0) {
		sendToLCD("Client: cannot open socket");
		die_with_error("");
	}
	if (connect(s, (struct sockaddr *) &result, sizeof(result))) {
		sendToLCD("No connection");
		die_with_error("");
	}
	close(s);

	while (1) {
		if (counter >= BUFFER_SIZE){
			s = socket(AF_INET, SOCK_STREAM, 0);
			if (s < 0) {
				sendToLCD("Client: cannot open socket");
				OSTaskDel(HTTP_PRIO);
			}
			if (connect(s, (struct sockaddr *) &result, sizeof(result))) {
				die_with_error("");
				OSTaskDel(HTTP_PRIO);
			}
			read = write(s,buff, counter);
			total += read;
			if( read < 0 ){
				sendToLCD("Lost connection");
				die_with_error("");
			}
			printf("Sent %d bytes to client. Total: %d\n", read, total);
			close(s);
			counter = 0;
		}
		int fill_level;
		while((fill_level = altera_avalon_fifo_read_level(INTERNET_FIFO_OUT_BASE)) > 0 && counter < BUFFER_SIZE){
			buff[counter] = (alt_u16) altera_avalon_fifo_read_fifo(INTERNET_FIFO_OUT_BASE,INTERNET_FIFO_IN_CSR_BASE);
			counter++;
		}
	}
}
Ejemplo n.º 2
0
/*****************************************************************************
 *
 * Description:
 *    Send data byte to LCD controller
 *
 ****************************************************************************/
void lcdWrdata (uint8 data)
{
	while (1)
	{
		if (SEMAFOR_SPI == 0)
		{
			SEMAFOR_SPI = 1;
			sendToLCD (1, data);
			SEMAFOR_SPI = 0;

			return;
		}
	}
}
Ejemplo n.º 3
0
/*****************************************************************************
 *
 * Description:
 *    Send data byte to LCD controller
 *
 ****************************************************************************/
void
lcdWrdata(tU8 data)
{
  sendToLCD(1, data);
}
Ejemplo n.º 4
0
/*****************************************************************************
 *
 * Description:
 *    Send command data to LCD controller
 *
 ****************************************************************************/
void
lcdWrcmd(tU8 data)
{
  sendToLCD(0, data);
}