03-05-2025 06:40 PM
I have jut got a new detector and they only provide python code with the method of TCP/IP to communicate with the detector. When I used the python, I can read the count from the detector but when I use the labview, it always show the error out 56, did someone know how to solve it, or it is because the labview did not have utf8 ? the python and labview is in the attachment
03-05-2025 07:00 PM
Please share the Python code and the equivalent LabVIEW code to ensure you've ported it correctly.
03-05-2025 07:04 PM
I think I upload the file, I upload it again, sorry for that. It seems that I cannot upload the python, here is the python
#!/usr/bin/env python
import socket
import matplotlib.pyplot as plt
import numpy as np
# open the device on the localhost, port 9999
t = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
t.connect(('127.0.0.1', 9999))
# read the server response
data = t.recv(512)
print(data.decode('utf8'))
# set the measurement times sweep from 50 to 500 ms
integration_times = 500
command = bytes("I," + str(integration_times) + '\n', "utf8")
print(command)
t.send(command)
data = t.recv(8192) # get the data
datastr = data.decode('utf8') # decode into a string
datasplit = datastr.split("\n") # split the lines
print(datasplit)
t.close()
03-05-2025 10:14 PM
You did not quite accurately translate it to LabVIEW, especially the '\n' part and missed a comma in the command
Please try the attached VI
03-06-2025 07:56 AM
Thanks for the information, really appreciate it. I try it but it has the same problem. I am wondering if it is the string still wrong, because when I print out from python, it shows like this, but in the code you provide, it is not the same. I am not very familiar with the labview so much, what do you think ?
03-06-2025 08:05 AM
Hi Qiushi,
@Qiushi11 wrote:
when I print out from python, it shows like this, but in the code you provide, it is not the same.
Either enlarge those string indicators (as noted by that arrow in the lower right corner) or switch them to \-code display mode...
03-06-2025 08:19 AM
Is it fine like that, it seems that the resulting string is still different with the python output.
03-06-2025 08:30 AM - edited 03-06-2025 08:30 AM
Hi Qiushi,
@Qiushi11 wrote:
Is it fine like that, it seems that the resulting string is still different with the python output.
What about setting the indicator to \-code display AND setting the displaymode indication to visible?
It's in the context menu of the indicator! (aka right-click menu)