Git Product home page Git Product logo

Comments (17)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Hello,
Can you please provide more information? Can you make sure that COM1 is free 
(try to
open it with Hyperterminal before running the slave)
Thanks

Original comment by [email protected] on 30 Nov 2009 at 5:10

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Hello

Yes COM1 is free and does work.
COM1 on PC
I also have other COM ports via USB/Serial devices and these show the same issue
Thanks

Original comment by [email protected] on 30 Nov 2009 at 7:43

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Can you try the following codes in a python console and see if you have the same
problems 

import serial
s = serial.Serial(port="COM1", baudrate=9600)
s.close()
s = serial.Serial(port=0, baudrate=9600)
s.close()
s = serial.Serial(port=0)
s.close()

Original comment by [email protected] on 1 Dec 2009 at 5:06

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Hello

Created test code (added print "Test" lines) - runs ok

Command Prompt dump:

C:\Temp\_py\modbus-tk-0.3.1\examples>python.exe mk_serialtest.py
Test 1
Test 2
Test 3

Running rtumaster_example.py (with port=0) gives the following:


C:\Temp\_py\modbus-tk-0.3.1\examples>python.exe rtumaster_example.py
2009-12-02 13:06:38,644 INFO    rtumaster_example.<module>      MainThread
connected
2009-12-02 13:06:38,644 DEBUG   modbus.execute  MainThread      -> 1-3-0-100-0-3
-68-20
2009-12-02 13:06:43,660 DEBUG   modbus.execute  MainThread      <-
Traceback (most recent call last):
  File "rtumaster_example.py", line 32, in <module>
    logger.info(master.execute(1, cst.READ_HOLDING_REGISTERS, 100, 3))
  File "build\bdist.win32\egg\modbus_tk\utils.py", line 28, in new
modbus_tk.modbus.ModbusInvalidResponseError: Response length is invalid 0

Running rtuslave_example.py (as supplied) gives the following:

C:\Temp\_py\modbus-tk-0.3.1\examples>python.exe rtuslave_example.py
running...
enter 'quit' for closing the server
server error: could not open port COM1: [Error 5] Access is denied.
quit
bye-bye

C:\Temp\_py\modbus-tk-0.3.1\examples>

Maybe slave is running ok?

Thanks




Original comment by [email protected] on 2 Dec 2009 at 1:13

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
I didn't succeed to simulate the problem but I am using virtual COM ports 
(com0com)
so it may be a difference. 
Do you see the "Access denied" at the very beginning?

Can you try to open the serial port in rtu_slave with serial.Serial(port=0,
baudrate=9600, bytesize=8, parity='N', stopbits=1, xonxoff=0)

I 've also committed a new version with more print logs (only modbus_rtu.py has 
been
modified) can you try to get it and send me what is printed for both Master and 
Slave?

Best

Original comment by [email protected] on 3 Dec 2009 at 6:17

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Hello

Yes - Access Denied come up at start

Copied file from svn browser.
results are the same see below: (changed Serial()) also)

C:\Temp\_py\modbus-tk-0.3.1\examples>python.exe rtuslave_example.py
running...
enter 'quit' for closing the server
server error: could not open port COM1: [Error 5] Access is denied.
quit
bye-bye

C:\Temp\_py\modbus-tk-0.3.1\examples>python.exe rtumaster_example.py
2009-12-03 19:56:40,148 INFO    rtumaster_example.<module>      MainThread
connected
2009-12-03 19:56:40,148 DEBUG   modbus.execute  MainThread      -> 1-3-0-100-0-3
-68-20
2009-12-03 19:56:45,148 DEBUG   modbus.execute  MainThread      <-
Traceback (most recent call last):
  File "rtumaster_example.py", line 32, in <module>
    logger.info(master.execute(1, cst.READ_HOLDING_REGISTERS, 100, 3))
  File "build\bdist.win32\egg\modbus_tk\utils.py", line 28, in new
modbus_tk.modbus.ModbusInvalidResponseError: Response length is invalid 0


Both programs are setup for COM1, there is nothing connected to COM1

Thanks

Original comment by [email protected] on 3 Dec 2009 at 8:01

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Hello Michael,

I think that you didn't reinstall teh new version. You must make a setup.py 
install
in order to see the new modbus_rtu taken into account. Then you'll see a new 
line
printed on the console which gives the name of the port and the status.

"Both programs are setup for COM1, there is nothing connected to COM1". One 
must be
on COM1 and the other on COM2. The 2 serial ports must be connected with a 
cross-over
RS232 cable. An alternative to the cross-over cable is using com0com.
make sure that both programs are NOT on the same port. If so, it is the cause 
of the
"Access Denied"

I hope it helps

Original comment by [email protected] on 3 Dec 2009 at 8:23

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Hello

I run each program on its own. (The sequecence shown in the command line dumb 
is what
I try). 

In the "C:\Temp\_py\modbus-tk-0.3.1\" folder I now have run setup.py install
Do I need to do something else ?
Will go get com0com and try that
Orginally looking for a modbus slave via COM1 (have master device/non pc)

Thanks

Original comment by [email protected] on 4 Dec 2009 at 10:05

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Any news on this problem?

Original comment by [email protected] on 5 Jan 2010 at 6:22

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
No news on this issue. I guess that it was a bad usage.

Original comment by [email protected] on 11 May 2010 at 9:49

  • Changed state: WontFix

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
I have the same issue, with the same symptoms as above.  Hardware is a Moxa
UPort1250, which works OK with Hyperterminal, RealTerm, PuTTY and same result 
with
RTU master example.

Would you like me to run any other tests or the instrumented/debug version you
mention above, if so how can I get it?

Original comment by [email protected] on 21 May 2010 at 3:46

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Also tested with built in port COM1 with same results, so not specific to Moxa.

Opening the port with serial.Serial("COM2") works fine and can stream data out, 
so
guess it's related to the way rtuslave_example.py opens it.

Original comment by [email protected] on 21 May 2010 at 3:49

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Modified RtuServer as attached to check for open port before opening.  This has
stopped the Access Denied message, so is hopefully the source of the problem?

May com0com lets you reopen already-opened ports, if you didn't see it when 
testing
previously?

Do you know of other MODBUS tools which will work over com0com?  I have been 
trying
modpoll.exe and QModbus but both seem to fail to recognise com0com.

Original comment by [email protected] on 21 May 2010 at 4:27

Attachments:

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Hello,
Thanks for the fix. I think that it is the right thing to do.
I'll look in detail and try to simulate the pb with and without. but I guess 
that
your fix is Ok

I 've succeed to use ModbusDoctor with com0com. I think that you must create a 
pair
COMx and COMy manually.

Original comment by [email protected] on 21 May 2010 at 8:01

  • Changed state: Accepted

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
I am looking more in details to your fix. Maybe I misunderstood but you 
mentionned a
problem with the RTU master and fixed in the RTU slave!!

Can you please clarify?

Best

Original comment by [email protected] on 21 May 2010 at 8:16

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Fault was noted in RTU slave example, fix was in RTU server, which is part of 
RTU
slave- lines 26-28 of rtuslave_example.py are:

if __name__ == "__main__":
    #Create the server
    server = modbus_rtu.RtuServer(serial.Serial(0))

Change was made in RtuServer within modbus_rtu.py

Hope that is clearer, thanks for the prompt response.

Original comment by [email protected] on 24 May 2010 at 8:07

from modbus-tk.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 30, 2024
Ok, I understand better. 

Your fix is valid but I think is different from the original problem. 

The 'access denied' may be a pure pyserial issue because modbus_tk doesn't open 
the
port itself in most cases. He takes and use a valid serial.Serial object. 

I've experienced a similar problem caused by the debug server of bottle. It can 
try
to open the port twice and cause the error.

I've added some test cases to make sure that the port can be reopened. see rev 
110.

I hope it helps

Original comment by [email protected] on 26 May 2010 at 3:06

  • Changed state: Fixed

from modbus-tk.

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.