This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DLPNIRNANOEVM: Connecting Arduino to DLPNIRNANOEVM through UART port

Part Number: DLPNIRNANOEVM

Hi Team,

Our customer is trying to connect the DLPNIRNANOEVM to Arduino MKR WIFI 1010 through the UART port. According to our customer,

I connected an external power to DLP NIR Nano, and connects four pins (1,2,3,and 4) to my Arduino board. I use the sample codes from DLP NIR Nano GUI app.cpp to generate UART commands. I use the Arduino Serial.write() and Serial.read() to send and receive commands. However, the Arduino board cannot receive any byte from DLP NIR Nano. It seems the connection is not built.

Should I connect all the 10 pins? And if the voltage is greater than 3.3V, will that affect the connection?

I understand that only pins 2-4 are required to use the UART port. He said in another email,

I connected the DLPNIRNANOEVM to my Windows OS, it works well, and there is no error status shown.

BTW, I tested the voltage of the expansion connector, pin 1 and 4 shows a voltage of 3.3V, but pin 3 has 0 voltage. Is this normal?
I connected pin 3 and 4 to my Arduino board tx and rx port, the corresponding rx has 3.35 voltage, but tx has 0 voltage. Will this be the case why I cannot receive any byte from serial?

I made mistakes when describing the serial sending, I sent an NNO_CMD, with 20 bytes, but the Serial write returns 0 bytes were sent. And when I try to read from the Serial, there are data there.

I enclosed pictures of how I connect my DLPNIRNANOEVM to my Arduino board. Both devices connect to external power. So they only connect via UART ports. I also enclosed my Arduino codes, I called the NNO_CMD_DLPC_ENABLE command.

      

btn_nirsetting.ino.zip

Regards,

Danilo

  • Hello Danilo,

    Welcome back to the forum!

    Can you customer confirm that the EVM and Arduino share a common ground and that the RX from one component is routed to TX of the other and vice versa?

    The NIRSCAN Nano UART interface operates at 3.3V. Please have your client confirm that the Arduino interface operates at this voltage as well.

    Regards,

    Austin

  • Hello Danilo,

    Need to check if EVM is getting adequate current too? Please refer to section 4.1 "External Power  supply requirement" (page 40) of the DLP NIR Nano EVM user guide.

    https://www.ti.com/lit/ug/dlpu030g/dlpu030g.pdf

    You can also refer the schematic available in reference design for details;

    https://www.ti.com/tool/TIDA-00554

    regards,

    Vivek

  • Hi Vivek and Austin,

    Our customer confirmed that the EVM and Arduino share a common ground and pin 3 (RX of Arduino) is connected to the TX of EVM while pin 4 (TX of Arduino) is connected to RX of EVM as shown in this picture below.

      

    I asked our customer to capture the waveform of TX and RX and here is his response.

    I don't have analog meter so I cannot show you the waveform. I have a level shifter, so I connect the RX, TX, GND, and input power of DLPNIRNANOEVM with my Arduino board via the shifter. I attached an image for that.

      

    I also tested the NNO_DLPCEnable command, I attached the screenshot of Serial output. Return of NNO_Getack() is 0, which I'm not sure if the command send/receive is successfully or not.

    Regards,

    Danilo

  • Hello Danilo,

    We will look into it. Meanwhile , Could you please confirm that EVM is booting properly i.e. the green LED is on and blinking? Please suggest them to try reset and wake button too.

    regards, 

    Vivek

  • Hi Vivek,

    Our customer shared a short video of his set-up showing the EVM is booting properly and there are data on the serial port. The ground of the DLPNIRNANOEVM is connected to the level converter as well as the ground of Arduino board. The DLPNIRNANOEVM is powered up by an external power supply.

    Regards,

    Danilo

  • Hello Danilo,

    Thank you for sharing the video. It will take us some time to review and analyze it. We will get back to you my middle of next week.

    regards,

    Vivek

  • Hi Vivek,

    We will wait for the updates. 

    Regards,

    Danilo

  • Hello Danilo,

    Thank you for your patience. 

    It is difficult issue  and we may be limited on how much we could help because we don't have the other hardware at our end to experiment.

    regards,

    Vivek

  • Hello Danilo,

    Could you please request the customer that the command packet is proper as mentioned in Section I of User's Guide.

    Also this seem to be a duplicate ticket: https://e2e.ti.com/support/dlp-products-group/dlp/f/dlp-products-forum/1084892/dlpnirnanoevm-no-response-over-uart-with-arduino and request you to follow up wih that thread too

    Thanks & Regards,

    Akhil

  • Hi Akhil,

    According to our customer,

    Thanks for the response. I have another question, are the RTS/CTS pins necessary for the connection?

    Regards,

    Danilo

  • Danilo,

    We will get back to you in a day. 

    Regards

    Mayank

  • Hi Danilo,

    By default the TIVA MCU has UART configured for Hardware flow control (RTS & CTS)

    RTS/CTS Pin connection is not necessary but is advisable to have a stable communication.

    Regards,

    Akhil

  • Hi Akhil,

    Thanks for the RTS&CTS info.

    I also tried to connect the UART pins with my laptop via a USB breakout, and use codes same as the DLPNIRNANOEVM GUI codes. The responses are exactly the same as when I'm using Arduino to connect the DLPNIRNANOEVM. The commands are successfully sent out, but no response from DLPNIRNANOEVM.

    I attached my connection image, screenshot of the results, and my codes here.

      

    testdlpserial.c
    #include <stdio.h>
    #include <sys/types.h>
    #include <termios.h>
    #include <fcntl.h>
    #include <stdlib.h>
    #include <sys/ioctl.h>
    #include <unistd.h>
    #include "NNOCommandDefs.h"
    #include "API.h"
    
    #define MAX_BYTES_TO_READ	50
    #define SERIAL_DEVICE	"/dev/ttys003"
    #define MAX_PACKET_SIZE 64
    #define MIN_PACKET_SIZE 64
    #define PASS 0
    #define FAIL -1
    #define SUCCESS 1
    
    static unsigned char OutputBuffer[MAX_PACKET_SIZE+2];
    static unsigned char InputBuffer[sizeof(nnoMessageStruct)+MIN_PACKET_SIZE];
    static unsigned char seqNum=0;
    static uint8 UARTWriteBuffer[1024 * 8];
    static uint8 ReadBuffer[1024 * 8];
    #define UARTMAXSIZE 8192
    static bool g_UARTConnected = true;
    int UART_Supported[62] = {1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,
                              1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1};
    
    int uartMesglength = 0;
    int UART_Device = 1;
    
    int NNO_SetUARTConnected(bool connected)
    {
        g_UARTConnected = connected;
        return PASS;
    }
    
    static int NNO_PrepReadCmd(uint32 cmd_key)
    /**
     * This function is private to this file. Prepares the read-control command packet for the given command code and copies it to OutputBuffer.
     *
     * @param   cmd  - I - USB command code.
     *
     * @return  0 = PASS
     *          -1 = FAIL
     *
     */
    {
        nnoMessageStruct msg;
    
        msg.head.flags.rw = 1; //Read
        msg.head.flags.reply = 1; //Host wants a reply from device
        msg.head.flags.dest = 0; //Projector Control Endpoint
        msg.head.flags.reserved = 0;
        msg.head.flags.resp = 0;
        msg.head.seq = 0;
    
        msg.payload.cmd = CMD_GET_CMD(cmd_key);
        msg.head.length = 2;
    
       if(cmd_key == NNO_CMD_FLASH_GET_CHKSUM)
        {
            msg.payload.data[2] = 0x00;
            msg.head.length += 1;
        }
    
        OutputBuffer[0]=0; // First byte is the report number
        memcpy(&OutputBuffer[1], &msg, (sizeof(msg.head)+sizeof(msg.payload.cmd) + msg.head.length));
    
        printf("SSUCCESS in NNO_PrepReadCmd\n");
        return PASS;
    }
    
    int Serial_Write(void *Data, unsigned long Length)
    {
    	printf("UART_Device = %d\n",UART_Device);
    	if(UART_Device < 0){
    		//THROW(ERR_NOT_INITIALIZED);
    		printf("check line\n");
    		printf("DEVICE NOT INITIALIZED _ Serial_Write\n");
    		exit(1);
    	}
    
    	if(write(UART_Device, Data, Length) < 0){
    		//THROW(FAIL);
    		printf("Failed to write to device");
    		exit(1);
    	}
        printf("Serial_Write SUCCESS!");
        return SUCCESS;
    }
    
    int Serial_WaitForData(uint32 Timeout)
    {
    	fd_set InputFD;
    	struct timeval TimeoutTimer;
    	struct timeval *Timer;
    
    	FD_ZERO(&InputFD);
    	FD_SET(UART_Device, &InputFD);
    
    	if(Timeout)
    	{
    		TimeoutTimer.tv_usec = Timeout;
    		TimeoutTimer.tv_sec = 0;
    		Timer = &TimeoutTimer;
    	}
    	else
    	{
    		Timer = NULL;
    	}
    
    	if(select(UART_Device + 1, &InputFD, NULL, NULL, Timer) == 0)
    		//return ERR_TIMEOUT;
    		return FAIL;
    
        return SUCCESS;
    }
    
    int Serial_TimeoutReadData(void *Data, uint32 Length, uint32 InitTimeout, uint32 Timeout)
    {
    	int Bytes;
    
    	if(UART_Device < 0){
    		//THROW(ERR_NOT_INITIALIZED);
    		printf("check linke_ timeoutreaddata");
    		perror("DEVICE NOT INITIALIZED _ Timeoutreaddata");
    		exit(1);
    	}
    	while(1)
    	{
    		if(ioctl(UART_Device, FIONREAD, &Bytes) < 0){
    			//THROW(FAIL);
    			perror("FIONREAD ioctl failed\n");
    			exit(6);
    		}
    
    		if(Bytes)
    		{
    			if(Bytes > Length)
    				Bytes = Length;
    
    			if(read(UART_Device, Data, Bytes) < 0){
    				//THROW(FAIL);
    				perror("Failed at read Uart_Device data");
    				exit(6);
    			}
    
    			Length -= Bytes;
    			Data = (uint8*)Data + Bytes;
    
    			if(Length == 0)
    				break;
    
    			InitTimeout = Timeout;
    		}
    
    		if(Serial_WaitForData(InitTimeout)<0){
    			//THROW_S(ERR_TIMEOUT);
    			perror("ERR_TIMEOUT");
    			exit(1);
    		}
    
    	}
    
        return SUCCESS;
    }
    
    int Serial_Read(void *Data, uint32 Length)
    {
    	return Serial_TimeoutReadData(Data, Length, 0, 0);
    }
    
    
    
    static int NNO_Read(int isUART)
    /**
     * This function is private to this file. This function is called to write the read control command and then read back a complete HID packet over USB
     * to InputBuffer.
     *
     * @return  number of bytes read
     *          -2 = nack from target
     *          -1 = error reading
     *
     */
    {
    
        nnoMessageStruct *pMsg = (nnoMessageStruct *)InputBuffer;
        short msg_len=MIN_PACKET_SIZE;
        printf("g_UARTConnected = %d\n",g_UARTConnected);
        if(g_UARTConnected && isUART)//UART_Supported[pMsg->payload.cmd])
        {
            memcpy(&UARTWriteBuffer[8],&OutputBuffer[1],65);
            pMsg  = (nnoMessageStruct *)&OutputBuffer[1];
            unsigned int Checksum = 0;
            for(int i = 8; i < pMsg->head.length + 12  ; i++)
            {
                Checksum += UARTWriteBuffer[i];
            }
    
            UARTWriteBuffer[4] = Checksum;
            UARTWriteBuffer[5] = Checksum >> 8;
            UARTWriteBuffer[6] = Checksum >> 16;
            UARTWriteBuffer[7] = Checksum >> 24;
    
            //write the head and tail
            UARTWriteBuffer[0] = UART_START_IND_BYTE_0;
            UARTWriteBuffer[1] = UART_START_IND_BYTE_1;
            UARTWriteBuffer[2] = UART_START_IND_BYTE_2;
            UARTWriteBuffer[3] = UART_START_IND_BYTE_3;
    
            UARTWriteBuffer[pMsg->head.length + 12] = UART_END_IND_BYTE_0;
            UARTWriteBuffer[pMsg->head.length + 13] = UART_END_IND_BYTE_1;
            UARTWriteBuffer[pMsg->head.length + 14] = UART_END_IND_BYTE_2;
            UARTWriteBuffer[pMsg->head.length + 15] = UART_END_IND_BYTE_3;
    
    
            nnouartMessageStruct *uMsg = (nnouartMessageStruct *)ReadBuffer;
            int read_length = 0;
            int ret;
            if(Serial_Write(UARTWriteBuffer,pMsg->head.length + 16) == 1)
            {
                printf("NNO_Read Serial_Write returns 1;");
                if(Serial_Read(ReadBuffer, 8 + sizeof(pMsg->head)) == 1)
                {
                    read_length = uMsg->head.length;
                    printf("NNO_Read Serial_Read returns 1;");
                }
    
                else
    		perror("FAIL at Serial_Read!=1\n");
                    return FAIL;
    
                if((ret = Serial_Read(&ReadBuffer[12], read_length + 4)) == 1)
                {
                    //Serial.println("NNO_Read Serial_Read read_length+4 returns 1;");
                    //skip the command name when copying from UART to USB structure
                    memcpy(&InputBuffer[0],&ReadBuffer[8],4);
                    memcpy(&InputBuffer[4],&ReadBuffer[14],read_length);
                    //Serial.println("read_length");
                    //Serial.println(read_length);
                    return read_length;
                }
                else if(ret < 1)
                {
                   return read_length;
                }
                else
                    return FAIL;
            }
            return FALSE;
        }
    //    int ret_val;
    //    int bytes_read=0;
    //
    //    if(USB_Write((void *)OutputBuffer) > 0)
    //    {
    //        while(bytes_read < msg_len)
    //        {
    //            ret_val =  USB_Read(&InputBuffer[bytes_read]);
    //            if(ret_val < 0)
    //            {
    //                return bytes_read;
    //            }
    //            else if (ret_val == 0)
    //                return NNO_READ_TIMEOUT;
    //
    //            if(bytes_read == 0)//On reading the header of a message, determine the message length or find if a NACK was received
    //            {
    //                if(pMsg->head.flags.resp == NNO_RESP_BUSY)
    //                    return NNO_CMD_BUSY;
    //                else if((pMsg->head.flags.resp == NNO_RESP_ERROR) || (pMsg->head.length == 0))
    //                    return NNO_CMD_NACK;
    //
    //                msg_len = sizeof(pMsg->head) + pMsg->head.length;
    //            }
    //            bytes_read += ret_val;
    //        }
    //        return bytes_read;
    //    }
        return FAIL;
    
    }
    
    int NNO_TestEEPROM(void)
    /**
     * Sends command to perform EEPROM test.
     *
     * (USB CMD OPCODE: BYTE1: 0x01, BYTE2: 0x01)
     *
     * @ingroup testAPI
     *
     * @return  PASS or FAIL
     *
     */
    {
        nnoMessageStruct msg;
        int ret_val;
        printf("In NNO_TESTEEPROM\n");
        NNO_PrepReadCmd(NNO_CMD_EEPROM_TEST);
        if((ret_val = NNO_Read(1)) > 0)
        {
    	printf("ret_val>0, is: %d",ret_val);
            memcpy(&msg, InputBuffer, 65);
            if(msg.payload.data[0] == 0)
                return PASS;
            else
                return FAIL;
        }
        printf("ret_val = %d",ret_val);
        //Serial.println("return ret_val");
        return ret_val;
    }
    
    int main()
    {
    	struct termios serial_port_settings;
    	int fd;
    	int retval;
    	char buf[256];
    	int i;
    
    	fd = open(SERIAL_DEVICE, O_RDWR);
    	if (fd < 0) {
    		perror("Failed to open SERIAL_DEVICE");
    		exit(1);
    	}
    	else{
    		printf("open serial at: 003\n");
    
    	}
    	//UART_Device=fd+1;
    	retval = tcgetattr(fd, &serial_port_settings);
    	if (retval < 0) {
    		perror("Failed to get termios structure");
    		exit(2);
    	}
    	else{
    		printf("tcgetattr at 003\n");
    	}
    
    	//setting baud rate to B115200
    	retval = cfsetospeed(&serial_port_settings, B115200);
    	if (retval < 0) {
    		perror("Failed to set 115200 output baud rate");
    		exit(3);
    	}
    	retval = cfsetispeed(&serial_port_settings, B115200);
    	if (retval < 0) {
    		perror("Failed to set 115200 input baud rate");
    		exit(4);
    	}
    	serial_port_settings.c_lflag &= ~(ICANON);
    	serial_port_settings.c_lflag &= ~(ECHO | ECHOE);
    	retval = tcsetattr(fd, TCSANOW, &serial_port_settings);
    	if (retval < 0) {
    		perror("Failed to set serial attributes");
    		exit(5);
    	}
    	printf("Successfully set the baud rate\n");
    	NNO_SetUARTConnected(true);
    	int nnotestres=NNO_TestEEPROM();	
            printf("NNO_TestEEPROM() = %d\n",nnotestres);
    	return 0;
    
    }
    

    Regards,

    Danilo

  • Hi Akhil,

    Regarding the other thread, it seems to be a similar inquiry but it is from a different customer and using another version of Arduino.

    Regards,

    Danilo

  • Hi Akhil,

    I just received this update from our customer,

    I noticed my device port was incorrect in my last screenshot, I changed my codes, and also tried to connect DLPNIRNANOEVM with my laptop via a level converter, the output still shows there is data sent out, but no response received.

    I attached the new screenshot and connection images, also my codes.

    The white micro-USB connected to the DLPNIRNANOEVM is just a power supply.

      

    testdlpserial (1).c
    #include <stdio.h>
    #include <sys/types.h>
    #include <termios.h>
    #include <fcntl.h>
    #include <stdlib.h>
    #include <sys/ioctl.h>
    #include <unistd.h>
    #include "NNOCommandDefs.h"
    #include "API.h"
    
    #define MAX_BYTES_TO_READ	50
    #define SERIAL_DEVICE	"/dev/ttys003"
    #define MAX_PACKET_SIZE 64
    #define MIN_PACKET_SIZE 64
    #define PASS 0
    #define FAIL -1
    #define SUCCESS 1
    
    static unsigned char OutputBuffer[MAX_PACKET_SIZE+2];
    static unsigned char InputBuffer[sizeof(nnoMessageStruct)+MIN_PACKET_SIZE];
    static unsigned char seqNum=0;
    static uint8 UARTWriteBuffer[1024 * 8];
    static uint8 ReadBuffer[1024 * 8];
    #define UARTMAXSIZE 8192
    static bool g_UARTConnected = true;
    int UART_Supported[62] = {1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,
                              1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1};
    
    int uartMesglength = 0;
    int UART_Device = 1;
    
    int NNO_SetUARTConnected(bool connected)
    {
        g_UARTConnected = connected;
        return PASS;
    }
    
    static int NNO_PrepReadCmd(uint32 cmd_key)
    /**
     * This function is private to this file. Prepares the read-control command packet for the given command code and copies it to OutputBuffer.
     *
     * @param   cmd  - I - USB command code.
     *
     * @return  0 = PASS
     *          -1 = FAIL
     *
     */
    {
        nnoMessageStruct msg;
    
        msg.head.flags.rw = 1; //Read
        msg.head.flags.reply = 1; //Host wants a reply from device
        msg.head.flags.dest = 0; //Projector Control Endpoint
        msg.head.flags.reserved = 0;
        msg.head.flags.resp = 0;
        msg.head.seq = 0;
    
        msg.payload.cmd = CMD_GET_CMD(cmd_key);
        msg.head.length = 2;
    
       if(cmd_key == NNO_CMD_FLASH_GET_CHKSUM)
        {
            msg.payload.data[2] = 0x00;
            msg.head.length += 1;
        }
    
        OutputBuffer[0]=0; // First byte is the report number
        memcpy(&OutputBuffer[1], &msg, (sizeof(msg.head)+sizeof(msg.payload.cmd) + msg.head.length));
    
        printf("SSUCCESS in NNO_PrepReadCmd\n");
        return PASS;
    }
    
    int Serial_Write(void *Data, unsigned long Length)
    {
    	printf("UART_Device = %d\n",UART_Device);
    	if(UART_Device < 0){
    		//THROW(ERR_NOT_INITIALIZED);
    		printf("check line\n");
    		printf("DEVICE NOT INITIALIZED _ Serial_Write\n");
    		exit(1);
    	}
    
    	if(write(UART_Device, Data, Length) < 0){
    		//THROW(FAIL);
    		printf("Failed to write to device");
    		exit(1);
    	}
        printf("Serial_Write SUCCESS!");
        return SUCCESS;
    }
    
    int Serial_WaitForData(uint32 Timeout)
    {
    	fd_set InputFD;
    	struct timeval TimeoutTimer;
    	struct timeval *Timer;
    
    	FD_ZERO(&InputFD);
    	FD_SET(UART_Device, &InputFD);
    
    	if(Timeout)
    	{
    		TimeoutTimer.tv_usec = Timeout;
    		TimeoutTimer.tv_sec = 0;
    		Timer = &TimeoutTimer;
    	}
    	else
    	{
    		Timer = NULL;
    	}
    
    	if(select(UART_Device + 1, &InputFD, NULL, NULL, Timer) == 0)
    		//return ERR_TIMEOUT;
    		return FAIL;
    
        return SUCCESS;
    }
    
    int Serial_TimeoutReadData(void *Data, uint32 Length, uint32 InitTimeout, uint32 Timeout)
    {
    	int Bytes;
    
    	if(UART_Device < 0){
    		//THROW(ERR_NOT_INITIALIZED);
    		printf("check linke_ timeoutreaddata");
    		perror("DEVICE NOT INITIALIZED _ Timeoutreaddata");
    		exit(1);
    	}
    	while(1)
    	{
    		if(ioctl(UART_Device, FIONREAD, &Bytes) < 0){
    			//THROW(FAIL);
    			perror("FIONREAD ioctl failed\n");
    			exit(6);
    		}
    
    		if(Bytes)
    		{
    			if(Bytes > Length)
    				Bytes = Length;
    
    			if(read(UART_Device, Data, Bytes) < 0){
    				//THROW(FAIL);
    				perror("Failed at read Uart_Device data");
    				exit(6);
    			}
    
    			Length -= Bytes;
    			Data = (uint8*)Data + Bytes;
    
    			if(Length == 0)
    				break;
    
    			InitTimeout = Timeout;
    		}
    
    		if(Serial_WaitForData(InitTimeout)<0){
    			//THROW_S(ERR_TIMEOUT);
    			perror("ERR_TIMEOUT");
    			exit(1);
    		}
    
    	}
    
        return SUCCESS;
    }
    
    int Serial_Read(void *Data, uint32 Length)
    {
    	return Serial_TimeoutReadData(Data, Length, 0, 0);
    }
    
    
    
    static int NNO_Read(int isUART)
    /**
     * This function is private to this file. This function is called to write the read control command and then read back a complete HID packet over USB
     * to InputBuffer.
     *
     * @return  number of bytes read
     *          -2 = nack from target
     *          -1 = error reading
     *
     */
    {
    
        nnoMessageStruct *pMsg = (nnoMessageStruct *)InputBuffer;
        short msg_len=MIN_PACKET_SIZE;
        printf("g_UARTConnected = %d\n",g_UARTConnected);
        if(g_UARTConnected && isUART)//UART_Supported[pMsg->payload.cmd])
        {
            memcpy(&UARTWriteBuffer[8],&OutputBuffer[1],65);
            pMsg  = (nnoMessageStruct *)&OutputBuffer[1];
            unsigned int Checksum = 0;
            for(int i = 8; i < pMsg->head.length + 12  ; i++)
            {
                Checksum += UARTWriteBuffer[i];
            }
    
            UARTWriteBuffer[4] = Checksum;
            UARTWriteBuffer[5] = Checksum >> 8;
            UARTWriteBuffer[6] = Checksum >> 16;
            UARTWriteBuffer[7] = Checksum >> 24;
    
            //write the head and tail
            UARTWriteBuffer[0] = UART_START_IND_BYTE_0;
            UARTWriteBuffer[1] = UART_START_IND_BYTE_1;
            UARTWriteBuffer[2] = UART_START_IND_BYTE_2;
            UARTWriteBuffer[3] = UART_START_IND_BYTE_3;
    
            UARTWriteBuffer[pMsg->head.length + 12] = UART_END_IND_BYTE_0;
            UARTWriteBuffer[pMsg->head.length + 13] = UART_END_IND_BYTE_1;
            UARTWriteBuffer[pMsg->head.length + 14] = UART_END_IND_BYTE_2;
            UARTWriteBuffer[pMsg->head.length + 15] = UART_END_IND_BYTE_3;
    
    
            nnouartMessageStruct *uMsg = (nnouartMessageStruct *)ReadBuffer;
            int read_length = 0;
            int ret;
            if(Serial_Write(UARTWriteBuffer,pMsg->head.length + 16) == 1)
            {
                printf("NNO_Read Serial_Write returns 1;");
                if(Serial_Read(ReadBuffer, 8 + sizeof(pMsg->head)) == 1)
                {
                    read_length = uMsg->head.length;
                    printf("NNO_Read Serial_Read returns 1;");
                }
    
                else
    		perror("FAIL at Serial_Read!=1\n");
                    return FAIL;
    
                if((ret = Serial_Read(&ReadBuffer[12], read_length + 4)) == 1)
                {
                    //Serial.println("NNO_Read Serial_Read read_length+4 returns 1;");
                    //skip the command name when copying from UART to USB structure
                    memcpy(&InputBuffer[0],&ReadBuffer[8],4);
                    memcpy(&InputBuffer[4],&ReadBuffer[14],read_length);
                    //Serial.println("read_length");
                    //Serial.println(read_length);
                    return read_length;
                }
                else if(ret < 1)
                {
                   return read_length;
                }
                else
                    return FAIL;
            }
            return FALSE;
        }
    //    int ret_val;
    //    int bytes_read=0;
    //
    //    if(USB_Write((void *)OutputBuffer) > 0)
    //    {
    //        while(bytes_read < msg_len)
    //        {
    //            ret_val =  USB_Read(&InputBuffer[bytes_read]);
    //            if(ret_val < 0)
    //            {
    //                return bytes_read;
    //            }
    //            else if (ret_val == 0)
    //                return NNO_READ_TIMEOUT;
    //
    //            if(bytes_read == 0)//On reading the header of a message, determine the message length or find if a NACK was received
    //            {
    //                if(pMsg->head.flags.resp == NNO_RESP_BUSY)
    //                    return NNO_CMD_BUSY;
    //                else if((pMsg->head.flags.resp == NNO_RESP_ERROR) || (pMsg->head.length == 0))
    //                    return NNO_CMD_NACK;
    //
    //                msg_len = sizeof(pMsg->head) + pMsg->head.length;
    //            }
    //            bytes_read += ret_val;
    //        }
    //        return bytes_read;
    //    }
        return FAIL;
    
    }
    
    int NNO_TestEEPROM(void)
    /**
     * Sends command to perform EEPROM test.
     *
     * (USB CMD OPCODE: BYTE1: 0x01, BYTE2: 0x01)
     *
     * @ingroup testAPI
     *
     * @return  PASS or FAIL
     *
     */
    {
        nnoMessageStruct msg;
        int ret_val;
        printf("In NNO_TESTEEPROM\n");
        NNO_PrepReadCmd(NNO_CMD_EEPROM_TEST);
        if((ret_val = NNO_Read(1)) > 0)
        {
    	printf("ret_val>0, is: %d",ret_val);
            memcpy(&msg, InputBuffer, 65);
            if(msg.payload.data[0] == 0)
                return PASS;
            else
                return FAIL;
        }
        printf("ret_val = %d",ret_val);
        //Serial.println("return ret_val");
        return ret_val;
    }
    
    int main()
    {
    	struct termios serial_port_settings;
    	int fd;
    	int retval;
    	char buf[256];
    	int i;
    
    	fd = open(SERIAL_DEVICE, O_RDWR);
    	if (fd < 0) {
    		perror("Failed to open SERIAL_DEVICE");
    		exit(1);
    	}
    	else{
    		printf("open serial at: 003\n");
    
    	}
    	UART_Device=fd;
    	retval = tcgetattr(fd, &serial_port_settings);
    	if (retval < 0) {
    		perror("Failed to get termios structure");
    		exit(2);
    	}
    	else{
    		printf("tcgetattr at 003\n");
    	}
    
    	//setting baud rate to B115200
    	retval = cfsetospeed(&serial_port_settings, B115200);
    	if (retval < 0) {
    		perror("Failed to set 115200 output baud rate");
    		exit(3);
    	}
    	retval = cfsetispeed(&serial_port_settings, B115200);
    	if (retval < 0) {
    		perror("Failed to set 115200 input baud rate");
    		exit(4);
    	}
    	serial_port_settings.c_lflag &= ~(ICANON);
    	serial_port_settings.c_lflag &= ~(ECHO | ECHOE);
    	retval = tcsetattr(fd, TCSANOW, &serial_port_settings);
    	if (retval < 0) {
    		perror("Failed to set serial attributes");
    		exit(5);
    	}
    	printf("Successfully set the baud rate\n");
    	NNO_SetUARTConnected(true);
    	int nnotestres=NNO_TestEEPROM();	
            printf("NNO_TestEEPROM() = %d\n",nnotestres);
    	return 0;
    
    }
    

    Regards,

    Danilo

  • Hello Danilo,

    This is noted. We will look at the recent information given from the customer and follow up next week.

    Regards,
    John

  • Hi Danilo,

    Thanks for sharing the source code.

    I see that the data header is being filled as a bit field. One thing that shoulld be considered is that bitfield structure are dependent on the endianess of the controller. I request them to ensure the data is being filled properly as per the command format mentioned in the users guide.

    If possible can we get some logs which shows the actual data being sent via uart in hex format for better understanding and debug.

    Please refer to the Section I and table - I.1  : User Guide

    Regards,

    Akhil

  • Hi Akhil,

    Our customer was able to to solved the issue through this process.

    I connected the DLPNIRNANOEVM UART pins (pin1,pin2,pin3 and pin4) to my Windows OS laptop by using a USB-UART bridge board. I use an external power for DLPNIRNANOEVM. Pin1 and pin2 are connected to a shift converter to the Power and GND of the USB-UART breakout board. Pin 3 and pin4 are directly connected to the USB-UART bridge board. I used the Serial.c functions to set up the serial port, and sends commands such as NNO_CMD_EEPROM_TEST, NNO_CMD_ADC_TEST, and NNO_CMD_DLPC_ENABLE to DLPNIRNANOEVM. And the device responded these commands via the UART connections to my laptop terminal.

    He would like to know if the DLPNIRNANOEVM is compatible with embedded system.

    Regards,

    Danilo

  • Hello Danilo,

    It is great to hear that your issue has been resolved. Thank you for reporting back your process that resolved the issue.

    The DLPNIRNANOEVM is compatible with other host processors outside of PCs.

    Regards,

    Austin