[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[microblaze-uclinux] Uart lite hanging
Greetings,
I'm having a problem with the uart lite stopping sending data after
a
few minutes.
I'm using a Xilinx Spartan3E 1600E Microblaze edition evaluation
board.
Bitstream and kernel generated from the Xilinx-Spartan3E1600-RevA-edk91
project.
The test code I used is very simple and consist of a continuous send of
100 'x' to the serial port. After a few minutes the program
hangs for no
apparent reason.
I can reproduce the error (with the same behaviour) even if the serial
cable is detached.
Tried with ttyS1, too.
Many thanks for any hints you could provide me.
Giulio Mazzoleni
---- CUT HERE ----
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SERNUM 1
int sendToSerial(unsigned int num, unsigned char *txBuff, int
bytesToSend);
int uart_dev[SERNUM];
int main(int argc, char *argv[])
{
unsigned int serNum;
char serString[SERNUM][15];
char debug_str[100];
memset (debug_str, 'x', sizeof(debug_str));
for (serNum = 0; serNum < SERNUM; ++serNum) {
sprintf (serString[serNum], "/dev/ttyS%d", serNum);
if ((uart_dev[serNum] = open(serString, O_WRONLY)) < 0)
{
perror (serString);
return 1;
}
}
while (1) {
for (serNum = 0; serNum < SERNUM; ++serNum) {
if (sendToSerial(serNum, debug_str, sizeof(debug_str)) < 0)
perror (serString[serNum]);
}
}
return 1;
}
int sendToSerial(unsigned int num, unsigned char *txBuff, int
bytesToSend)
{
int ret, bytesSent = 0;
char *serStr[] = {"PC", "DBG"};
static int errors[SERNUM];
if (bytesToSend == 0)
return 0;
do {
ret = write(uart_dev[num], txBuff + bytesSent, bytesToSend -
bytesSent);
if (ret > 0)
bytesSent += ret;
else {
errors[num]++;
break;
}
} while (bytesSent < bytesToSend);
if (bytesSent > 0)
printf("\n ---> Sent %d bytes to %s (%d)\n", bytesSent,
serStr[num],
errors[num]);
#if DEBUG > 3
{
int i;
for (i=0; i<bytesSent; ++i)
printf ("0x%02x ", (unsigned char) txBuff[i]);
printf ("\n");
}
#endif
if (bytesSent > 0)
return bytesSent;
else
return -1;
}
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/