GithubHelp home page GithubHelp logo

Comments (9)

Krolken avatar Krolken commented on May 29, 2024

Does the port connect or not. Do you not get data back?

from iec62056-21.

GreenSkiLLz avatar GreenSkiLLz commented on May 29, 2024

Does the port connect or not. Do you not get data back?

No i don't get any data back, Im using this script to check what usb ports are available and choose the one belonging to my EMH.

import serial.tools.list_ports
ports = serial.tools.list_ports.comports()

for port, desc, hwid in sorted(ports):
        print("{}: {} [{}]".format(port, desc, hwid))

when i run the code in my initial comment it does not Connect and just returns a Timeout error after some Seconds.

When using the EMH Software that came with the Lzqj-xc " Emh-Combi-master" it works just fine. The Emh is not the Problem. Do i have to change Something when declarating the client?

from iec62056-21.

Krolken avatar Krolken commented on May 29, 2024

It shouldn't need to. It starts at 300 baud and then the init process is done.

Just to be clear: you are using an optical probe?

I know the modems in EMH meters are annoying so when you send over TCP you need to emulate 7E0 over tcp. But via the optical port is was never a problem.

CombiMaster has a communications log window that you can open and see what is sent to the meter. Do you mind pasting that to see if there is a need to add something.

I also know over RS485 on you need to add the address in the init message.

Also set up a standard logger with log level DEBUG so you can see where the program is halting. If you get timeout error it should be because it did not reveive a response and EMH never answers if they get the wrong data in, could be because of wrong speed if it has been set to be constant. But maybe it doesnt fail in the first message exchange but in any of the following.

from iec62056-21.

GreenSkiLLz avatar GreenSkiLLz commented on May 29, 2024

Yes i am using the USB connection of the optical probe. Not sure where to look for the communication log window but im gonna try and find it :D
Going to debug the messages today, if i get any info of value i'll message again.
Thanks 👍

from iec62056-21.

Krolken avatar Krolken commented on May 29, 2024

Also see if you can get the python program log output

from iec62056-21.

GreenSkiLLz avatar GreenSkiLLz commented on May 29, 2024

So my Debug says this:

10:20:42,885 INFO: Staring init sequence
10:20:42,886 INFO: Sending request message: RequestMessage(device_address='')
10:20:42,937 DEBUG: Sent b'/?!\r\n' over transport: SerialTransport
10:20:42,938 DEBUG: Resting for 0.25 seconds
Traceback (most recent call last):
File "c:\Users\md\Desktop\TESTINGSTUFF\Serial.py", line 103, in
iec()
File "c:\Users\md\Desktop\TESTINGSTUFF\Serial.py", line 27, in iec
data_answer = client.standard_readout()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\md\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\iec62056_21\client.py", line 186, in standard_readout self.startup()
File "C:\Users\md\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\iec62056_21\client.py", line 150, in startup
ident_msg = self.read_identification()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\md\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\iec62056_21\client.py", line 264, in read_identification
data = self.transport.simple_read(start_char="/", end_char="\x0a")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\md\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\iec62056_21\transports.py", line 147, in simple_read
raise TimeoutError(f"Read in {self.class.name} timed out")
TimeoutError: Read in SerialTransport timed out

My Code is the same as before except with the debuglogger:

def iec():
    from iec62056_21.client import Iec6205621Client
    import logging

    logging.basicConfig(
        level=logging.DEBUG,
        format="%(asctime)s,%(msecs)d %(levelname)s: %(message)s",
        datefmt="%H:%M:%S",
    )

    client = Iec6205621Client.with_serial_transport(port="COM5")
    client.connect()
    data_answer = client.standard_readout()
    print(data_answer)


iec()

Treid with the EMH Programm after the Timeout and it worked liked usual so the EMH is working correctly but not with the python script. :(

It seems to stop while recieving the identification.

from iec62056-21.

GreenSkiLLz avatar GreenSkiLLz commented on May 29, 2024

ok i think i got it, you were right, the speed is set to be constant, changing the baudrate in transports.py to 9600 semed to solve the problem, now its a matte rof permissions.

inside of transports.py i changed:

    def connect(self):
        """
        Creates a serial port.
        """
        self.port = serial.Serial(
            self.port_name,
            baudrate=9600, #<-- changed 300 to 9600
            parity=serial.PARITY_EVEN,
            stopbits=serial.STOPBITS_ONE,
            bytesize=serial.SEVENBITS,
            writeTimeout=0,
            timeout=self.timeout / 2,
            rtscts=False,
            dsrdtr=False,
            xonxoff=False,
        )

from iec62056-21.

Krolken avatar Krolken commented on May 29, 2024

OK. Good.
Standard readout usually doesn't have permissions?
Are you trying to access programming mode? Standard password is 00000000

from iec62056-21.

GreenSkiLLz avatar GreenSkiLLz commented on May 29, 2024

no i am just trying to readout P.02 but atm im just trying to use the standart readout to see if its working.

Now i get this permission Error:

11:02:11,528 INFO: Staring init sequence
11:02:11,528 INFO: Sending request message: RequestMessage(device_address='')
11:02:11,587 DEBUG: Sent b'/?!\r\n' over transport: SerialTransport
11:02:11,588 DEBUG: Resting for 0.25 seconds
11:02:12,282 DEBUG: Received b'/EMH5\@01LZQJL0013E\r\n' over transport: SerialTransport
11:02:12,282 INFO: Received identification message: IdentificationMessage(identification='@01LZQJL0013E', manufacturer='EMH', switchover_baudrate_char='5')
11:02:12,282 INFO: Sending AckOptionsSelect message: AckOptionSelectMessage(baud_char='5', mode_char='0')
11:02:12,338 DEBUG: Sent b'\x06050\r\n' over transport: SerialTransport
11:02:12,338 DEBUG: Resting for 0.25 seconds
Traceback (most recent call last):
File "c:\Users\md\Desktop\TESTINGSTUFF\Serial.py", line 103, in
iec()
File "c:\Users\md\Desktop\TESTINGSTUFF\Serial.py", line 27, in iec
data_answer = client.standard_readout()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\md\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\iec62056_21\client.py", line 194, in standard_readout self.transport.switch_baudrate(self.switchover_baudrate)
File "C:\Users\md\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\iec62056_21\transports.py", line 274, in switch_baudrate
self.port = self.port = serial.Serial(
^^^^^^^^^^^^^^
File "C:\Users\md\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\serial\serialwin32.py", line 33, in init
super(Serial, self).init(*args, **kwargs)
File "C:\Users\md\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\serial\serialutil.py", line 244, in init
self.open()
File "C:\Users\md\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\serial\serialwin32.py", line 64, in open
raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'COM5': PermissionError(13, 'Zugriff verweigert', None, 5)

I guess its because it tries to open the port twice maby?

EDIT: It Works now, i changed nothing but it works now, whatever... Now imma go figgure out how to read the P.02 Profile... Case Closed, Thanks for Help

from iec62056-21.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.