jefffhaynes / XBee

A .NET library for XBee wireless controllers
MIT License
41 stars 17 forks source link

S2C Support for DIO 10 thru DIO 14 #17

Closed PaulNoto closed 8 years ago

PaulNoto commented 8 years ago

Hi Jeff, I downloaded the latest source for the XBee library. DIO0 thru DIO9 work. However, DIO10 thru DIO14 still don't work. I applied my mods to the source and got them working again. I was really hoping you would think about adding library support for DIOs above 9. I'm not sure how you would do it in the big picture of all the different flavors of XBee. This is what I'm doing to support my S2C version of the XBee.

// INPUT OUTPUT CONFIGURATION

// MODIFIED: InputOutputConfigurationCommand.cs
// Above D9 starts with P0 so I changed the Constructor

public InputOutputConfigurationCommand( InputOutputChannel channel ) :
         base( (int)channel > 9 ? $"P{(int)channel - 10}" : $"D{(int)channel}" ) {
}

// EXTENDED: InputOutputChannel.cs
// It stopped at Channel 9
public enum InputOutputChannel {
    Channel0 = 0,
    Channel1 = 1,
    Channel2 = 2,
    Channel3 = 3,
    Channel4 = 4,
    Channel5 = 5,
    Channel6 = 6,
    Channel7 = 7,
    Channel8 = 8,
    Channel9 = 9,
    Channel10 = 10,
    Channel11 = 11,
    Channel12 = 12,
    Channel13 = 13,
    Channel14 = 14
}

// EXTENDED: DigitalSampleState.cs
public enum DigitalSampleState : ushort {
    None = 0x0,
    Input0 = 0x1,
    Input1 = 0x2,
    Input2 = 0x4,
    Input3 = 0x8,
    Input4 = 0x10,
    Input5 = 0x20,
    Input6 = 0x40,
    Input7 = 0x80,
    Input8 = 0x100,
    Input9 = 0x200,
    Input10 = 0x400,
    Input11 = 0x800,
    Input12 = 0x1000,
    Input13 = 0x2000,
    Input14 = 0x4000,

    All = Input0 | Input1 | Input2 | Input3 | Input4 | Input5
            | Input6 | Input7 | Input8 | Input9 | Input10 | Input11 | Input12 | Input13 | Input14
}

// EXTENDED: DigitalSampleChannels.cs
public enum DigitalSampleChannels : ushort {
    None = 0x0,
    Input0 = 0x1,
    Input1 = 0x2,
    Input2 = 0x4,
    Input3 = 0x8,
    Input4 = 0x10,
    Input5 = 0x20,
    Input6 = 0x40,
    Input7 = 0x80,
    Input8 = 0x100,
    Input9 = 0x200,
    Input10 = 0x400,
    Input11 = 0x800,
    Input12 = 0x1000,
    Input13 = 0x2000,
    Input14 = 0x4000
}

// ADDED TO: RxIndicatorSampleExtFrame.cs
[SerializeWhen( "DigitalChannels", DigitalSampleChannels.Input13,
     ConverterType = typeof( BitwiseAndConverter ), ConverterParameter = DigitalSampleChannels.Input13 )]
[SerializeWhen( "DigitalChannels", DigitalSampleChannels.Input14,
     ConverterType = typeof( BitwiseAndConverter ), ConverterParameter = DigitalSampleChannels.Input14 )]

Anyway, I am using these mods and they do work for the S2C XBee. My favorite was finding out that Configuration Commands above D9 start over with P0. To me, the engineer that came up with that, just wanted to do something really evil ! ! !

jefffhaynes commented 8 years ago

Ok, sorry about that. I'll try to get it working this weekend.

On Fri, May 13, 2016 at 7:54 AM -0700, "PaulNoto" notifications@github.com wrote:

Hi Jeff,

I downloaded the latest source for the XBee library. DIO0 thru DIO9 work. However, DIO10 thru DIO14 still don't work. I applied my mods to the source and got them working again. I was really hoping you would think about adding library support for DIOs above 9. I'm not sure how you would do it in the big picture of all the different flavors of XBee. This is what I'm doing to support my S2C version of the XBee.

// INPUT OUTPUT CONFIGURATION

// MODIFIED: InputOutputConfigurationCommand.cs // Above D9 starts with P0 so I changed the Constructor

public InputOutputConfigurationCommand( InputOutputChannel channel ) : base( (int)channel > 9 ? $"P{(int)channel - 10}" : $"D{(int)channel}" ) { }

// EXTENDED: InputOutputChannel.cs // It stopped at Channel 9 public enum InputOutputChannel { Channel0 = 0, Channel1 = 1, Channel2 = 2, Channel3 = 3, Channel4 = 4, Channel5 = 5, Channel6 = 6, Channel7 = 7, Channel8 = 8, Channel9 = 9, Channel10 = 10, Channel11 = 11, Channel12 = 12, Channel13 = 13, Channel14 = 14 }

// EXTENDED: DigitalSampleState.cs public enum DigitalSampleState : ushort { None = 0x0, Input0 = 0x1, Input1 = 0x2, Input2 = 0x4, Input3 = 0x8, Input4 = 0x10, Input5 = 0x20, Input6 = 0x40, Input7 = 0x80, Input8 = 0x100, Input9 = 0x200, Input10 = 0x400, Input11 = 0x800, Input12 = 0x1000, Input13 = 0x2000, Input14 = 0x4000,

All = Input0 | Input1 | Input2 | Input3 | Input4 | Input5
        | Input6 | Input7 | Input8 | Input9 | Input10 | Input11 | Input12 | Input13 | Input14

}

// EXTENDED: DigitalSampleChannels.cs public enum DigitalSampleChannels : ushort { None = 0x0, Input0 = 0x1, Input1 = 0x2, Input2 = 0x4, Input3 = 0x8, Input4 = 0x10, Input5 = 0x20, Input6 = 0x40, Input7 = 0x80, Input8 = 0x100, Input9 = 0x200, Input10 = 0x400, Input11 = 0x800, Input12 = 0x1000, Input13 = 0x2000, Input14 = 0x4000 }

// ADDED TO: RxIndicatorSampleExtFrame.cs [SerializeWhen( "DigitalChannels", DigitalSampleChannels.Input13, ConverterType = typeof( BitwiseAndConverter ), ConverterParameter = DigitalSampleChannels.Input13 )] [SerializeWhen( "DigitalChannels", DigitalSampleChannels.Input14, ConverterType = typeof( BitwiseAndConverter ), ConverterParameter = DigitalSampleChannels.Input14 )]

Anyway, I am using these mods and they do work for the S2C XBee. My favorite was finding out that Configuration Commands above D9 start over with P0. To me, the engineer that came up with that, just wanted to do something really evil ! ! !

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

jefffhaynes commented 8 years ago

Pushed as part of 3.0.1. Thanks!

PaulNoto commented 8 years ago

Tested. DIO 0 thru DIO 14 work for Configuration and Change Detection. Thanks Jeff.

jefffhaynes commented 8 years ago

Awesome!  No problem 

On Sat, May 14, 2016 at 4:55 PM -0700, "PaulNoto" notifications@github.com wrote:

Tested. DIO 0 thru DIO 14 work for Configuration and Change Detection. Thanks Jeff.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub