cancelar
Mostrando resultados para 
Pesquisar então 
Você quer dizer: 

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
Mensagem 1 de 11
1.045Exibições

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
0 Kudos
Mensagem 2 de 11
1.041Exibições

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
Mensagem 3 de 11
1.035Exibições

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
0 Kudos
Mensagem 4 de 11
1.000Exibições

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
Mensagem 5 de 11
965Exibições

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
Mensagem 6 de 11
963Exibições

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
Mensagem 7 de 11
958Exibições

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
Mensagem 8 de 11
953Exibições

I try again:

Qiushi11_0-1741306983835.png

Qiushi11_1-1741306994547.png

By the way I try to combine python and labview together and it seems work. 

Qiushi11_2-1741307155698.png

this is the def function

#!/usr/bin/env python

import socket

def get_server_data():
# Open the device on 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).decode('utf8')

# Set the measurement times sweep from 50 to 500 ms
integration_time = 500

# Start an intensity measurement and read the data
command = bytes(f"I,{integration_time}\n", "utf8")
t.send(command)

data = t.recv(8192).decode('utf8') # Get the data

t.close()

return data # Return the result as a string

 

 

 

 

 

0 Kudos
Mensagem 9 de 11
916Exibições

Hi Qiushi,

 


@Qiushi11 wrote:

I try again:


You still don't show \-code display in your frontpanel…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Mensagem 10 de 11
903Exibições