[ale] Anyone familiar with Python?

Alex Carver agcarver+ale at acarver.net
Tue Mar 8 17:31:36 EST 2016


No, there's no module for these devices.  The company supports their own
programming environment (very similar to LabView) and provides the
protocol reference so that the devices can be used elsewhere but no code
is offered for anything outside their program.

This is Python 2.7.  I can't use 3.0 or above because I'm having to
integrate this hardware into an existing code base that communicates
with even more specialized hardware.  I know there's a few things in the
existing code base that won't migrate easily and would require a lot of
work to rewrite.

On 2016-03-08 14:23, Jay Lozier wrote:
> Just curious, but is it possible that there might be Python module
> available to do what you want?
> 
> Also, which flavor of Python are you using?
> 
> Jay
> 
> 
> On 03/08/2016 04:12 PM, Alex Carver wrote:
>> Ok, so this should be fun since I've spent the past hour and a half on
>> Google and haven't really gotten anywhere.
>>
>> I'm writing some code to control data collection modules.  Physically,
>> all the modules are hanging off an RS485 bus with a single wire to the
>> computer.  Each of the modules has a set of very core commands
>> (specifically for things like fetching the module name, firmware number,
>> and base configuration) and then it has module specific commands that
>> vary depending on the type of module (read voltage inputs, set relays on
>> outputs, etc.)  All of the modules share the same protocol for comms.
>>
>> So my original thought was to create a class which contained the very
>> bottom stuff, serial I/O/ that would handle the basic serial functions
>> and the protocol.  Let's call this data_collectors.
>>
>> I then thought to make a subclass of data_collectors that contains the
>> more specific functions mapped to the protocol commands (e.g. I'd have a
>> get_voltage() function for the specific voltage input module and a
>> set_relay() function for a relay output module).  The modules each have
>> their own address.
>>
>> So in code form (some pseudo code in here, too for brevity):
>>
>> <file is my_data_collector_file>
>> class data_collector(object):
>>
>>     serial_port = None
>>
>>     def open_port(self, tty=''):
>>         self.serial_port = serial.open(tty)
>>
>>     def write_port(...):
>>
>>     def read_port(...):
>>
>>     def get_module_name(...):
>>         write_port()
>>         read_port()
>>
>> class voltage_input(data_collector):
>>     __init__(self, module_address):
>>         self.module_address  = module_address
>>
>>     get_voltage(self, channel):
>>         <stuff here including write_port() read_port()>
>>
>> class relay_output(data_collector):
>>     __init__(self, module_address):
>>         self.module_address = module_address
>>
>>
>>     set_relay(self, channel, value):
>>         <stuff here including value validation, write_port(), read_port()
>>
>>
>> The goal was to be able to import this block of code and then do the
>> following (somehow):
>>
>> import my_data_collector_file as my_dcf
>>
>> dcf.open_port(tty=...0)  #somehow do this, not sure how
>> gauges = dcf.voltage_input(module_address=1)
>> valves = dcf.relay_output(module_address=2)
>>
>>
>> Right now, with the same structure I can execute the gauges = and valves
>> = lines but they get independent copies of the base class.  I want to
>> share the base class (so the port opens and stays open) among all of the
>> subclasses but have the subclasses behave individually (since they each
>> have their own set of commands that don't overlap).
>>
>> I haven't figured out if there's a way to accomplish this even if
>> there's a third call (as above with the dcf.open_port) to just get
>> everything started.
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
> 



More information about the Ale mailing list