Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message #10

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
26 changes: 17 additions & 9 deletions source/pcic/client.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
from ..static.formats import error_codes, serialization_format
from o2x5xx import json, re, io
import matplotlib.image as mpimg
import binascii
import socket
import struct
import json
import re
import io
import o2x5xx
Copy link
Collaborator

@Galoshi Galoshi Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import from source instead of an installed library.
A customer cloning the repo for the first time does not own the o2x5xx lib

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kottanidisan see comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, the import statements need to be left as they are.

For testing changes like these I suggest to create a virtual environment where you install the o2x5xx-python packages and try a simple import o2x5xx afterwards. With the current state of the branch to be merged you will get the error

    from o2x5xx import json, re, io
ImportError: cannot import name 'json' from partially initialized module 'o2x5xx' (most likely due to a circular import) (/tmp/venv/lib/python3.10/site-packages/o2x5xx-0.2-py3.10.egg/o2x5xx/__init__.py)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kottanidisan Maybe a check like this can be done automatically by github for a branch?



class Client(object):
def __init__(self, address, port):
# open raw socket
self.pcicSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.pcicSocket.connect((address, port))
self.recv_counter = 0
self.debug = False
self.debugFull = False
sessionstatus = self.rpcdevice.getParameter("OperatingMode")
if sessionstatus == "0":
self.pcicSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.pcicSocket.connect((address, port))
self.recv_counter = 0
self.debug = False
self.debugFull = False
self.rpcdevice = o2x5xx.O2x5xxRPCDevice()

elif sessionstatus == "1":
raise RuntimeError("Sensor is in Parametrization Mode. Please close the ifmVisionAssistant and retry.")

else:
raise RuntimeError("Sensor is in simulation mode at the moment.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Maybe @Galoshi can confirm whether this is in fact the desired check and whether this is sufficient.


def __del__(self):
self.close()
Expand All @@ -35,7 +43,7 @@ def recv(self, number_bytes):
data = data + data_part
self.recv_counter += number_bytes
return data

def close(self):
"""
Close the socket session with the device.
Expand Down