2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 05:16:45 +00:00

support V_2_05 Protocol Version (wich 1-wire-correlation ids)

git-svn-id: https://svn.fhem.de/fhem/trunk@3191 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ntruchsess 2013-05-17 22:23:52 +00:00
parent 680a785275
commit 66db096b60
2 changed files with 75 additions and 6 deletions

View File

@ -249,6 +249,59 @@ use constant (
}, # /Constants for Version 2.4
V_2_05 => {
MAX_DATA_BYTES => 64, # max number of data bytes in non-Sysex messages
# message command bytes (128-255/0x80-0xFF)
DIGITAL_MESSAGE => 0x90, # send data for a digital pin
ANALOG_MESSAGE => 0xE0, # send data for an analog pin (or PWM)
REPORT_ANALOG => 0xC0, # enable analog input by pin #
REPORT_DIGITAL => 0xD0, # enable digital input by port pair
SET_PIN_MODE => 0xF4, # set a pin to INPUT/OUTPUT/PWM/etc
REPORT_VERSION => 0xF9, # report protocol version
SYSTEM_RESET => 0xFF, # reset from MIDI
START_SYSEX => 0xF0, # start a MIDI Sysex message
END_SYSEX => 0xF7, # end a MIDI Sysex message
# extended command set using sysex (0-127/0x00-0x7F)
RESERVED_COMMAND => 0x00, # 2nd SysEx data byte is a chip-specific command (AVR, PIC, TI, etc).
ANALOG_MAPPING_QUERY => 0x69, # ask for mapping of analog to pin numbers
ANALOG_MAPPING_RESPONSE => 0x6A, # reply with mapping info
CAPABILITY_QUERY => 0x6B, # ask for supported modes and resolution of all pins
CAPABILITY_RESPONSE => 0x6C, # reply with supported modes and resolution
PIN_STATE_QUERY => 0x6D, # ask for a pin's current mode and value
PIN_STATE_RESPONSE => 0x6E, # reply with a pin's current mode and value
EXTENDED_ANALOG => 0x6F, # analog write (PWM, Servo, etc) to any pin
SERVO_CONFIG => 0x70, # set max angle, minPulse, maxPulse, freq
STRING_DATA => 0x71, # a string message with 14-bits per char
ONEWIRE_DATA => 0x73, # OneWire read/write/reset/select/skip/search request + read/search reply
SHIFT_DATA => 0x75, # shiftOut config/data message (34 bits)
I2C_REQUEST => 0x76, # send an I2C read/write request
I2C_REPLY => 0x77, # a reply to an I2C read request
I2C_CONFIG => 0x78, # config I2C settings such as delay times and power pins
REPORT_FIRMWARE => 0x79, # report name and version of the firmware
SAMPLING_INTERVAL => 0x7A, # set the poll rate of the main loop
SCHEDULER_DATA => 0x7B, # createtask/deletetask/addtotask/schedule/querytasks/querytask request and querytasks/querytask reply
SYSEX_NON_REALTIME => 0x7E, # MIDI Reserved for non-realtime messages
SYSEX_REALTIME => 0x7F, # MIDI Reserved for realtime messages
# pin modes
INPUT => 0x00, # digital pin in digitalOut mode
OUTPUT => 0x01, # digital pin in digitalInput mode
ANALOG => 0x02, # analog pin in analogInput mode
PWM => 0x03, # digital pin in PWM output mode
SERVO => 0x04, # digital pin in Servo output mode
SHIFT => 0x05, # shiftIn/shiftOut mode
I2C => 0x06, # pin included in I2C setup
ONEWIRE => 0x07,
# Deprecated entries
deprecated => [
qw( FIRMATA_STRING SYSEX_I2C_REQUEST SYSEX_I2C_REPLY SYSEX_SAMPLING_INTERVAL )
],
}, # /Constants for Version 2.5
}
);

View File

@ -744,6 +744,11 @@ sub packet_onewire_request {
$subcommand |= $ONE_WIRE_COMMANDS->{READ_REQUEST_BIT};
push @data,$args->{read} & 0xFF;
push @data,($args->{read}>>8) & 0xFF;
if ($self->{protocol_version} ne 'V_2_04') {
my $id = (defined $args->{id}) ? $args->{id} : 0;
push @data,$id &0xFF;
push @data,($id>>8) & 0xFF;
}
}
if (defined $args->{delay}) {
$subcommand |= $ONE_WIRE_COMMANDS->{DELAY_REQUEST_BIT};
@ -774,13 +779,24 @@ sub handle_onewire_reply {
and do { #PIN,COMMAND,ADDRESS,DATA
my @data = unpack_from_7bit(@$sysex_data);
my $device = shift_onewire_device_from_byte_array(\@data);
if ($self->{protocol_version} eq 'V_2_04') {
my $device = shift_onewire_device_from_byte_array(\@data);
return {
pin => $pin,
command => 'READ_REPLY',
device => $device,
data => \@data
return {
pin => $pin,
command => 'READ_REPLY',
device => $device,
data => \@data
};
} else {
my $id = shift @data;
$id += (shift @data)<<8;
return {
pin => $pin,
command => 'READ_REPLY',
id => $id,
data => \@data
};
};
};