Python install on vanilla raspbian

General Discussion

Python install on vanilla raspbian

Postby venture1981 » Sat Aug 22, 2015 4:03 pm

I am seeing an error in my python2.7 install of alarmdecoder on stock raspbian. Must I use the custom raspbian image? I am planning to use a AD2USB device.
I have both python3 and python2.7 installed, but only python-pip is installed (no python3-pip).
I downloaded the latest alarmdecoder zip file from https://github.com/nutechsoftware/alarmdecoder
Unzipped it and ran "pip2.7 install alarmdecoder"
Here is my error mesage:

Command /usr/bin/python -c "import setuptools;__file__='/home/pi/alarmdecoder-master/build/cryptography/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-m6D4tm-record/install-record.txt failed with error code 1 in /home/pi/alarmdecoder-master/build/cryptography
Storing complete log in /home/pi/.pip/pip.log

It appears the the install made significant progress, but it breaking at the cryptography part.
Any help would be appreciated.
Thank you.
venture1981
newt
newt
 
Posts: 5
Joined: Sat Aug 22, 2015 3:48 pm

Re: Python install on vanilla raspbian

Postby kevin » Sat Aug 22, 2015 4:49 pm

Do you have setuptools installed? https://pypi.python.org/pypi/setuptools
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: Python install on vanilla raspbian

Postby venture1981 » Sat Aug 22, 2015 7:38 pm

Thanks Kevin. I am using the raspbian "python-pip" package which has setuptools. It looks like I was missing the raspbian packages "python-dev" and "libffi-dev"... once I installed those I installed fine without any messages.

I am trying to change my AD2USB's device address from 18 to 31. Could you help me with screen command?
I got my port from dmesg... ttyUSB0 and used the "stty -F /dev/ttyUSB0" command to get the following response:

speed 19200 baud; line = 0;
kill = ^H; min = 100; time = 2;
-icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo

I then used this command:

screen /dev/ttyUSB0 19200,cs8,-ixon,-ixoff

I get no response from the device when I send the "!" command. Do you think my screen command is wrong?

Thanks.
venture1981
newt
newt
 
Posts: 5
Joined: Sat Aug 22, 2015 3:48 pm

Re: Python install on vanilla raspbian

Postby kevin » Sat Aug 22, 2015 8:16 pm

According to the start guide found here: http://www.alarmdecoder.com/wiki/images ... tartv2.pdf
The baud rate for AD2USB is 115200
screen /dev/ttyUSB0 115200 should do the trick. Provided /dev/ttyUSB0 is indeed the AD2USB device. Also make sure the AD2USB at least has power from the alarm panel - it needs this to function.
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: Python install on vanilla raspbian

Postby venture1981 » Sat Aug 22, 2015 9:19 pm

Thanks again Kevin. Screen worked perfectly and I saw the alarm status in the screen session after the change in configuration.
One more question... are the python scripts (like examples/basics.py and test/test_devices.py) meant to be run individually? I ran each of those scripts but got enumeration errors. When I manually connect to the AD2USB with "screen", I specified /dev/ttyUSB0 as the target, how do the scripts know which device the AD2USB is? Is there a configuration file that I need to update somewhere?
venture1981
newt
newt
 
Posts: 5
Joined: Sat Aug 22, 2015 3:48 pm

Re: Python install on vanilla raspbian

Postby mathewss » Sat Aug 22, 2015 9:53 pm

Ok a few thinks to think about when building your own appliance.

#1 Shared access to the AlarmDecoder.
Because of the nature of ports on Linux or Windows they do handle well being connected from multiple programs at the same time. On Linux this causes unexpected behaviour and on Windows it just fails.

If you have screens open to /dev/ttyUSB0 then other programs will have unexpected results of they also try to open the port.

To solve this many years ago I wrote ser2sock. This allows multiple programs to share the device on a given port.

By default we install ser2sock on our appliance images to connect to the Ad2Pi board. It can easily be configured to connect to an AD2USB.
Image

The example you mentioned here
https://github.com/nutechsoftware/alarm ... /basics.py
Code: Select all
        # Retrieve the first USB device
        device = AlarmDecoder(USBDevice.find())


This example was written to hunt down and find the AlarmDecoder on a USB interface. We also allow you use the library to connect to any ser2sock connected AlarmDeocder.
https://github.com/nutechsoftware/alarm ... example.py

Code: Select all
# Retrieve an AD2 device that has been exposed with ser2sock on localhost:10000.
        device = AlarmDecoder(SocketDevice(interface=(HOSTNAME, PORT)))


This example just connects to /dev/ttyUSB0
https://github.com/nutechsoftware/alarm ... ialport.py
Code: Select all
        # Retrieve the specified serial device.
        device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))

So the library is very flexible but you still need to decide if you have a tighly connected port to your own app and no one else uses the device or if it is a shared resource among a cloud of apps that you run to manage everything.


Best Regards
Sean M.
mathewss
Moderator
Moderator
 
Posts: 188
Joined: Fri Dec 06, 2013 11:14 am

Re: Python install on vanilla raspbian

Postby kevin » Sat Aug 22, 2015 10:09 pm

The USBDevice class enumerates the USB Ports and tries to find connected devices - it relies on an implementation of libusb and libusb is known to have issues sometimes - for this we recommend using the SerialDevice or SocketDevice classes - and if you wish to share the device among multiple scripts - a SocketDevice and ser2sock is required.

Just an FYI - our image available for download is vanilla raspbian + all required mods to use an alarmdecoder device + ser2sock + webapp preinstalled. The webapp already has many different ways to configure notifications based off alarm state - depending on your project, you can leverage the functionality of the image we have prepared. By default with our image you can utilize the SocketDevice class to do your bidding on top of the functionality already built in.
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: Python install on vanilla raspbian

Postby venture1981 » Sun Aug 23, 2015 1:05 pm

Thank you Sean and Kevin. I have serialport.py working great! Sorry to ask more questions, is it possible for me to log chime events? I was wanting to look at the raw messages and update a log file with Chime events (and their time/date). I see a new alarmdecoder message being seen on a Chime event, but I can't see any changes of hex bits in the stream (to absolutely identify it as a chime). Would I need to disconnect my alarm system's horn (to not sound) and manually enable and disable alarm events to be able to create a log file? I mainly use my alarm system for the chime feature.

I would love to be able to log events from individual sensors (like a different event for each door in my house). Is there a debug mode for a VISTA10SE where all events are broadcast to the keypad? I don't mind if the alarm system is not operational.

Thank you for your help! This project has been really fun so far.
venture1981
newt
newt
 
Posts: 5
Joined: Sat Aug 22, 2015 3:48 pm

Re: Python install on vanilla raspbian

Postby mathewss » Sun Aug 23, 2015 4:31 pm

It is possible to watch section #1 for "Beep" indications and then take action but I am not 100% sure on the part of our API for this. I will ask on Monday.

The API has a zone tracking feature built in that can capture events for each zone and preform actions based upon that event. Again I will defer to Monday to get some actual details on the howto on this as well.

Glad you are having FUN!!

Re
Sean M
mathewss
Moderator
Moderator
 
Posts: 188
Joined: Fri Dec 06, 2013 11:14 am

Re: Python install on vanilla raspbian

Postby kevin » Sun Aug 23, 2015 5:49 pm

The library provides the number of beeps in the message - you can access message.beeps - see the Message class

Things like message.timestamp are also available.
Code: Select all
device.on_message += handle_message

function handle_message( sender, message):
    print sender, message.raw, message.beeps, message.timestamp


For zones, you can add event handlers to the
device.on_zone_fault and device.on_zone_restore events

Code: Select all
device.on_zone_fault += handle_zone_fault

function handle_zone_fault( sender, zone ):
    print 'zone faulted!', zone


You can also look at RFXMessage class for RF zones.
Code: Select all
device.on_rfx_message += handle_rfx

function handle_rfx(sender, message):
    if message.serial_number == '0123456789' and message.loop[0] == True:
        print message.serial_number, 'triggered loop #1'
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am


Return to General

Who is online

Users browsing this forum: No registered users and 7 guests

cron