LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP

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 

0 Kudos
Message 1 of 8
(127 Views)

Please share the Python code and the equivalent LabVIEW code to ensure you've ported it correctly.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 8
(123 Views)

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()

0 Kudos
Message 3 of 8
(117 Views)

You did not quite accurately translate it to LabVIEW, especially the '\n' part and missed a comma in the command

 

santo_13_0-1741234457236.png

 

Please try the attached VI

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 8
(82 Views)

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 ?

Qiushi11_3-1741269312886.png

 

Qiushi11_1-1741269238971.png

Qiushi11_2-1741269243769.png

 

0 Kudos
Message 5 of 8
(47 Views)

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...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(45 Views)

Is it fine like that, it seems that the resulting string is still different with the python output.

Qiushi11_0-1741270663687.png

Qiushi11_1-1741270671811.png

 

0 Kudos
Message 7 of 8
(40 Views)

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)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 8
(35 Views)