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.

OPT4001DNPQ1EVM: IndexError in Latte

Part Number: OPT4001DNPQ1EVM
Other Parts Discussed in Thread: OPT4001

Hello experts,

 

I’m trying to run OPT4001DNPQ1EVM-GUI version 1.0.1 with OPT4001DNPQ1EVM.

After the following steps, I faced IndexError in devInit.py, and GUI window did not show up.

 

  1. Connected the EVM with USB cable. -> Green LED on EVM lit.
  2. Run Latte
  3. The application stops with following error logs.

 

#======

#Executing .. OPT4001/OPT4001DNPQ1_EVM/devInit.py

#Start Time 2023-10-11 16:47:05.912000

Device detected: OPT4001DNP-Q1EVM

#Error: index 0 is out of bounds for axis 0 with size 0

# "OPT4001/OPT4001DNPQ1_EVM/devInit.py", line 66, in

# IndexError: index 0 is out of bounds for axis 0 with size 0

#

#

#Done executing .. OPT4001/OPT4001DNPQ1_EVM/devInit.py

#End Time 2023-10-11 16:47:06.443000

#Execution Time = 0.531000137329 s

#================ ERRORS:1, WARNINGS:0 ================#

 

Please let me know what is wrong?

 

Thanks & Regards,

-Shibata

  • Hi Shibata,

    Do you have any other usb devices connected besides mouse and keyboard? I have noticed this issue occurring when some other devices were connected. Let me know if this helps.

    Thank you,

    Brent Elliott

  • Hi Brent,

    I disconnected Logicool Unifying receiver for wireless mouse. Still seeing the same issue.

    Regards,

    -Shibata

  • Hi Taro,

    Are the comports showing up in device manager when unplugging and replugging in the EVM?

    Thank you,

    Brent Elliott

  • Hi Brent,

     

    Yes I see 2 com ports in device manager.

     

     

     

    As you can see below message in the log, the EVM seems to be detected via com ports.

     

    Device detected: OPT4001DNP-Q1EVM

     

    Regards,

    -Shibata

  • Hi Shibata,

    In the command line of Latte are you able to execute the commands "log(evmList.control)" and "log(evmList.data)"? Are both of these lists empty or just one of them?

  • Hi Brent,

    Please find the results below.

    >>> log(evmList.control)

    [u'COM26']
    #======

    >>> log(evmList.data)

    []
    #======

    Regards,

    -Shibata

  • Hi Shibata,

    Let me try to recreate this issue with an EVM and see if I can debug. Please give me a day at most to look into.

    Thank you,

    Brent Elliott

  • Hi Brent,

    Sorry, I wrongly copied the log in the previous post.

    Please find the correct one below.

    >>> log(evmList.control)

    [u'COM26']
    #======

    >>> log(evmList.data)

    []
    #======

    Thanks

    -Shibata

  • Hi Shibata,

    Can you replace the contents of mEVMSelector.py with the following in Latte?

    Let me know what the log outputs when you relaunch the EVM software.

    import serial
    from serial.tools import list_ports 
    import numpy as np
    import re
    import time
    import globalDefs as Globals
    
    
    def send(ser, cmd):
    	ser.write(cmd+'\r')
    	time.sleep(1e-3)
    	timeOut = 0xFFFF
    	while ((not ser.inWaiting()) and timeOut > 0):
    		timeOut -= 1
    	if (timeOut > 0):
    		retCode = ser.readline()
    		retCode = retCode.splitlines()[0]
    		retSp = retCode.split(':')
    	return retSp, retCode, timeOut
    
    
    def sendCheck(ser, cmd):
    	retSp, retCode, timeOut = send(ser, cmd)
    	assert timeOut > 0
    	assert retSp[1] == '0'
    	return retSp, retCode, timeOut
    
    def decodeHwrz(s):
    	a = ""
    	for i in range(3):
    		a += chr(int(s[2*i:2*i+2]))
    	return a
    
    class EVMSelector():
    	VID=0x2047
    	PID=0x0A3C
    	dv=-1
    	def __init__(self):
    		portList=np.array([])
    		for port in serial.tools.list_ports.comports():
    			#print 'VID is 0x%04x PID is 0x%04x'%(port.vid,port.pid)
    			if((port.vid==self.VID) and (port.pid==self.PID)):
    				portList=np.append(portList,port)
    		if(np.size(portList)%2):
    			Globals.error('Number of ports with EVM\'s VID and PID seems to be odd number. Expected even number')
    			return
    		
    		locList=dict()
    		
    		self.control=np.array([])
    		self.data=np.array([])
    		self.controlP=np.array([])
    		self.dataP=np.array([])
    		#print portList
    #		import imp 
    #		mMSP5503Programmer=imp.load_source('mMSP5503Programmer','c:/Asterix/projects/OPT3101/OPT3101EVMrevE3_TIDAWideFov/'+'/mMSP5503Programmer.py')
    		for i,port in enumerate(portList):
    			try:
    				ser=serial.Serial(port.device,9600)
    				#print "Passed to open",port.device
    			except:
    				#print "Failed to open",port.device
    				Globals.log('Serial port [%s] Locked'%port.device)
    				continue
    			ser.write('HWR?'+'\r')
    			storeSize=5
    			time.sleep(1e-3)
    			timeOut=0xFFFF
    			while((not ser.inWaiting()) and timeOut>0):
    				timeOut-=1
    			if(timeOut>0):
    				retCode=ser.readline()
    				retCode=retCode.splitlines()[0]
    				retSp=retCode.split(':')
    				#print "Appending ",retCode
    				if(retSp[1]=='C'):
    					retSp2, retCode2, timeOut2 = send(ser, 'HWRF')
    					if (timeOut2 > 0):
    						if (retSp2[1] == 'F'):
    							Globals.error("Invalid EVM detected")
    							return	
    						elif (int(retSp2[1]) >= 1):
    							sendCheck(ser, 'FLS!R')
    							z = sendCheck(ser, 'FLSH')[0]
    							Globals.log(z[2])
    							Globals.log('%02d'%storeSize)
    							assert z[2] == '%02d'%storeSize
    							r = [sendCheck(ser, 'FLSR')[0][2] for i in range(storeSize)]
    							sendCheck(ser, 'FLS!R')
    							s = "".join([decodeHwrz(st) if i != 1 else st[2:6]
    							            for i, st in enumerate(r)])
    							Globals.log("Device detected: " + s)
    							assert s == "OPT4001DNP-Q1EVM"
    							self.dv=1
    					else:
    						Globals.error('Communication Error.')
    						assert 0
    					self.controlP=np.append(self.controlP,port)
    					self.control=np.append(self.control,port.device)
    					Globals.log('control is [%s]'%port.device)
    				elif(retSp[1]=='D'):
    					self.dataP=np.append(self.dataP,port)
    					self.data=np.append(self.data,port.device)
    					Globals.log('data is [%s]'%port.device)
    				else:
    					Globals.log('[%s] unidentified'%port.device)
    			ser.close()
    		if(not (np.size(self.controlP)==np.size(self.dataP))):
    			Globals.error('Number of Control and Data ports not matched. Unlock all COM ports')
    			return
    		for c0,port in enumerate(self.controlP):
    			try:
    				ser=serial.Serial(port.device,9600)
    			except:
    				Globals.log('Serial port [%s] Locked'%port)
    				continue
    			ser.write('HWRX%d'%(c0+1)+'\r')
    			ser.close()
    		dataOrder=[]
    		for c0,port in enumerate(self.dataP):
    			try:
    				ser=serial.Serial(port.device,9600)
    			except:
    				Globals.log('Serial port [%s] Locked'%port)
    				continue
    			ser.write('HWRX'+'\r')
    			time.sleep(1e-3)
    			timeOut=0xFFFF
    			while((not ser.inWaiting()) and timeOut>0):
    				timeOut-=1
    			if(timeOut>0):
    				retCode=ser.readline()
    				retCode=retCode.splitlines()[0]
    				retSp=retCode.split(':')
    				dataOrder.append(np.uint8(retSp[1])-1)
    			ser.close()
    		self.data=self.data[dataOrder]
    		self.dataP=self.dataP[dataOrder]
    		#for c0 in np.arange(np.size(
    		return 
    		
    if __name__ == '__main__':
    	evmList=EVMSelector()
    	for c0 in np.arange(evmList.control.shape[0]):
    		print "Control Port for EVM %d is "%c0,evmList.control[c0]
    		print "Data    Port for EVM %d is "%c0,evmList.data[c0]
    	

    Thank you,

    Brent Elliott

  • Hi Brent,

    Please find blow logs:

    #======

    #Executing .. OPT4001/OPT4001DNPQ1_EVM/devInit.py

    #Start Time 2023-10-21 12:37:30.957000

    data is [COM25]

    05

    05

    Device detected: OPT4001DNP-Q1EVM

    control is [COM26]

    #Error: index 0 is out of bounds for axis 0 with size 0

    # "OPT4001/OPT4001DNPQ1_EVM/devInit.py", line 66, in

    # IndexError: index 0 is out of bounds for axis 0 with size 0

    #

    #

    #Done executing .. OPT4001/OPT4001DNPQ1_EVM/devInit.py

    #End Time 2023-10-21 12:37:31.480000

    #Execution Time = 0.523000001907 s

    #================ ERRORS:1, WARNINGS:0 ================#

    Thanks,

    -Shibata

  • Hi Shibata,

    When you disconnected the mouse, were there any other comports showing up in device manager besides the ones from the EVM? Just tested and was getting an issue with a mouse connected but the issue was resolved when disconnecting the mouse. I know you tried with your mouse disconnected but just wanted to double check.

    Thank you,

    Brent Elliott

  • Hi Brent,

    Please find below screenshot in both cases with/without Mouse connected.

    In both cases I saw the same issue.

    Best regards,

    -Shibata

  • Hi Shibata,

    I'm gonna bring this over to email.

    Thank you,

    Brent Elliott