Altera_Forum
Honored Contributor
8 years agoNios II and Python
I am trying to send char bytes from my fpga to a python program, the data bytes are hexadecimal data, and those values will be plotted in a GUI table. The nios code is
unsigned char temp =0xa; unsigned char temp1 =0xb; unsigned char temp2 =0xc; while(1) { sendFloat(temp); sendFloat(temp1); sendFloat(temp2); } return0; } void sendFloat( unsigned char n) { char number[20]; int i=0; snprintf(number, sizeof(number),"%u", n); while(i<20){ IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE,number[i]); delay(); i++; } IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE,'\n');} The Python code is import serial ser= serial.Serial('COM5',baudrate =115200, timeout=1) while 1: fpgadata=ser.readline() print(fpgadata)