[ECOS] read from user port

Harri Siirtola harri.siirtola@vtt.fi
Tue Mar 11 11:00:00 GMT 2003


On Mon, 2003-03-10 at 17:40, Katerina Malatara wrote:
 > hi,
 > i work with a e7t board and i try to read from user port. I have connect 
the
 > user port with com2 of my PC.
 > The PC read some data from a file store them in a buffer and then it send
 > them  through serial port to the board. The board must receive the data and
 > response by sending some other data.
 >
 > I use baudrate 38400.
 >
 > The PC use this function in a loop in order to send all the data in the
 > buffer
 > void outbyte(int fd, char c)
 > {
 > 	int n;
 >
 > 	n = write(fd, &c, 1);
 > 	if (n < 1) {
 > 		printf("Error %d: Can't write to serial port\n",n);
 > 		return;
 > 	}
 > }
 >
 > And board use the function
 > char inbyte(cyg_io_handle_t handle)
 > {
 > 	char temp[1];
 > 	Cyg_ErrNo n;
 > 	cyg_uint32 len = 1;
 >
 > 	n = cyg_io_read(handle, temp, &len);
 > 	if(n != ENOERR) {
 > 		diag_printf("Error %d: Can't write to serial port\n",n);
 > 		exit();
 > 	}
 > 	return (temp[0]);
 > }
 >
 > but receive only the last character.
 >
 > I can't understand where is the problem.

Do you use the receive function in a loop as well? Or do you have an ISR to 
empty the receive buffer? If all you get is the last char I suspect you 
don't read all chars (or you may store every incoming char to the same 
location).

	Harri


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list