d0ugal / python-rfxcom

A Python 3.3+ library for working with your RFXTrx and automating your home.
BSD 3-Clause "New" or "Revised" License
8 stars 10 forks source link

100% cpu hang #19

Closed oroulet closed 9 years ago

oroulet commented 10 years ago

Hi, I just received a new device and I am trying to make it work. but the rfcom sample just hangs with 100%cpu. How can I debug that kind of thing? I tried to add debug from asyncio import get_event_loop from logging.config import dictConfig from sys import stdout

LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s %(levelname)-8s %(name)-35s %(message)s' }, }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'stream': stdout, 'formatter': 'standard' }, 'file': { 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'formatter': 'standard', 'filename': '/tmp/rfxcom.log', 'maxBytes': 10 * 1024 * 1024, }, }, 'loggers': { 'rfxcom': { 'handlers': ['console', 'file', ], 'propagate': True, 'level': 'DEBUG', } }, }

from rfxcom.transport import AsyncioTransport

dev_name = '/dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1XPT6J4-if00-port0' loop = get_event_loop()

def handler(packet):

Print out the packet - the string representation will show us the type.

print(packet)
# Each packet will have a dictionary which contains parsed data.
print(packet.data)

# You can access the raw bytes from the packet too.
print(packet.raw)

try: dictConfig(LOGGING) rfxcom = AsyncioTransport(dev_name, loop, callback=handler) loop.run_forever() finally: loop.close()

python all.py 2014-08-24 09:41:55,875 INFO rfxcom.transport.AsyncioTransport Starting with individual callback: <function handler at 0x7f5dc3a95b70> 2014-08-24 09:41:55,876 INFO rfxcom.transport.AsyncioTransport Attaching writer for setup. 2014-08-24 09:41:55,876 INFO rfxcom.transport.AsyncioTransport Removing setup writer. 2014-08-24 09:41:55,877 INFO rfxcom.transport.AsyncioTransport Adding reader to prepare to receive. 2014-08-24 09:41:55,877 INFO rfxcom.transport.AsyncioTransport Flushing the RFXtrx buffer. 2014-08-24 09:41:55,878 INFO rfxcom.transport.AsyncioTransport Writing the reset packet to the RFXtrx. (blocking) 2014-08-24 09:41:55,878 INFO rfxcom.transport.AsyncioTransport WRITE: 0x0d 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 2014-08-24 09:41:55,879 INFO rfxcom.transport.AsyncioTransport Wating 0.4s 2014-08-24 09:41:56,280 INFO rfxcom.transport.AsyncioTransport Write the status packet (blocking) 2014-08-24 09:41:56,280 INFO rfxcom.transport.AsyncioTransport WRITE: 0x0d 0x00 0x00 0x01 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 2014-08-24 09:41:56,281 INFO rfxcom.transport.AsyncioTransport Adding mode packet to the write queue (blocking) 2014-08-24 09:41:56,281 INFO rfxcom.transport.AsyncioTransport WRITE: 0x0d 0x00 0x00 0x01 0x03 0x53 0x00 0x00 0x0e 0x2f 0x00 0x00 0x00 0x00 2014-08-24 09:41:56,282 INFO rfxcom.transport.AsyncioTransport Adding the queued writer next loop iteration.

Reset receiver/transceiver:0D 00 00 00 00 00 00 00 00 00 00 00 00 00

Get Status:0D 00 00 01 02 00 00 00 00 00 00 00 00 00

0D0100010253B2008C2701020000 Packettype = Interface Message subtype = Interface Response Sequence nbr = 1 response on cmnd = Get Status Transceiver type = 433.92MHz Firmware version = 178 Hardware version = 1.2 Undec off X10 enabled ARC enabled AC enabled .....

d0ugal commented 10 years ago

Hi,

I'm out on vacation for two weeks from today. I can try and help you when I get back if you still need it.

Sorry I can't help sooner.

Dougal

On Sun, Aug 24, 2014 at 8:45 AM, oroulet notifications@github.com wrote:

Hi, I just received a new device and I am trying to make it work. but the rfcom sample just hangs with 100%cpu. How can I debug that kind of thing? I tried to add debug from asyncio import get_event_loop from logging.config import dictConfig from sys import stdout LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s %(levelname)-8s %(name)-35s %(message)s' }, }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'stream': stdout, 'formatter': 'standard' }, 'file': { 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'formatter': 'standard', 'filename': '/tmp/rfxcom.log', 'maxBytes': 10 * 1024 * 1024, }, }, 'loggers': { 'rfxcom': { 'handlers': ['console', 'file', ], 'propagate': True, 'level': 'DEBUG', } }, } from rfxcom.transport import AsyncioTransport dev_name = '/dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1XPT6J4-if00-port0' loop = get_event_loop() def handler(packet):

Print out the packet - the string representation will show us the type.

print(packet)
# Each packet will have a dictionary which contains parsed data.
print(packet.data)
# You can access the raw bytes from the packet too.
print(packet.raw)

try: dictConfig(LOGGING) rfxcom = AsyncioTransport(dev_name, loop, callback=handler) loop.run_forever() finally: loop.close() python all.py 2014-08-24 09:41:55,875 INFO rfxcom.transport.AsyncioTransport Starting with individual callback: <function handler at 0x7f5dc3a95b70> 2014-08-24 09:41:55,876 INFO rfxcom.transport.AsyncioTransport Attaching writer for setup. 2014-08-24 09:41:55,876 INFO rfxcom.transport.AsyncioTransport Removing setup writer. 2014-08-24 09:41:55,877 INFO rfxcom.transport.AsyncioTransport Adding reader to prepare to receive. 2014-08-24 09:41:55,877 INFO rfxcom.transport.AsyncioTransport Flushing the RFXtrx buffer. 2014-08-24 09:41:55,878 INFO rfxcom.transport.AsyncioTransport Writing the reset packet to the RFXtrx. (blocking) 2014-08-24 09:41:55,878 INFO rfxcom.transport.AsyncioTransport WRITE: 0x0d 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 2014-08-24 09:41:55,879 INFO rfxcom.transport.AsyncioTransport Wating 0.4s 2014-08-24 09:41:56,280 INFO rfxcom.transport.AsyncioTransport Write the status packet (blocking) 2014-08-24 09:41:56,280 INFO rfxcom.transport.AsyncioTransport WRITE: 0x0d 0x00 0x00 0x01 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 2014-08-24 09:41:56,281 INFO rfxcom.transport.AsyncioTransport Adding mode packet to the write queue (blocking) 2014-08-24 09:41:56,281 INFO rfxcom.transport.AsyncioTransport WRITE: 0x0d 0x00 0x00 0x01 0x03 0x53 0x00 0x00 0x0e 0x2f 0x00 0x00 0x00 0x00 2014-08-24 09:41:56,282 INFO rfxcom.transport.AsyncioTransport Adding the queued writer next loop iteration.

Reset receiver/transceiver:0D 00 00 00 00 00 00 00 00 00 00 00 00 00

Get Status:0D 00 00 01 02 00 00 00 00 00 00 00 00 00

0D0100010253B2008C2701020000 Packettype = Interface Message subtype = Interface Response Sequence nbr = 1 response on cmnd = Get Status Transceiver type = 433.92MHz Firmware version = 178 Hardware version = 1.2 Undec off X10 enabled ARC enabled AC enabled

.....

Reply to this email directly or view it on GitHub: https://github.com/d0ugal/python-rfxcom/issues/19

oroulet commented 10 years ago

when hanging the red led on the box is solid red until I ctrl-C

bamthomas commented 9 years ago

I don't know if it is the same problem, but I notice that rfxcom module was taking 100% CPU without hanging. I made a cProfile and saw that it was in the python3.4/asyncio/base_events.py, python3.4/selectors.py and python3.4/asyncio/selector_events.py that were the main cpu time. cf http://stackoverflow.com/questions/31526544/asyncio-python-module-takes-100-cpu

If someone has a clue...

d0ugal commented 9 years ago

Sorry, this project is not currently maintained by me. I would support anyone that wants to take it on.

d0ugal commented 9 years ago

I believe this was fixed by #21