├── bin_libs
├── .keep
├── x64
│ ├── .keep
│ ├── libusb-1.0.dll
│ ├── libhamlib-2.dll
│ ├── libgcc_s_seh-1.dll
│ └── libwinpthread-1.dll
├── x86
│ ├── .keep
│ ├── libusb0.dll
│ ├── libusb-1.0.dll
│ ├── libhamlib-2.dll
│ ├── libgcc_s_sjlj-1.dll
│ └── libwinpthread-1.dll
└── libhamlib.so.2.1.1
├── app.config
├── IModeValue.cs
├── IChannelList.cs
├── RigException.cs
├── IConfigurationParameter.cs
├── x86
├── ModeValue32.cs
├── ChannelList32.cs
├── NativeRig32.cs
├── NativeRig32v2.cs
├── ConfigurationParameter32.cs
├── ChannelCapability32.cs
├── RigStateNative32.cs
├── RigStateNative32v2.cs
└── RigCapsNative32.cs
├── x64
├── ModeValue64.cs
├── ChannelList64.cs
├── NativeRig64.cs
├── NativeRig64v2.cs
├── ConfigurationParameter64.cs
├── ChannelCapability64.cs
├── RigStateNative64v2.cs
├── RigStateNative64.cs
├── RigCapsNative64.cs
└── RigCapsNative64v2.cs
├── Utils
├── IntPtrExtensions.cs
├── TextNameAttribute.cs
├── CastedList.cs
└── Library.cs
├── HamLibSharpTest
├── HamLibSharpTest.csproj
├── Properties
│ └── AssemblyInfo.cs
└── Program.cs
├── RigVfo.cs
├── RigCaps
├── Properties
│ └── AssemblyInfo.cs
└── RigCaps.csproj
├── Properties
└── AssemblyInfo.cs
├── README.md
├── IChannelCapability.cs
├── IRigStateNative.cs
├── HamLibSharp.sln
├── Structs.cs
├── HamLibPortNative.cs
├── HamLibSharp.csproj
├── .gitignore
├── IRigCapsNative.cs
├── HamLib.cs
└── Enums.cs
/bin_libs/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/bin_libs/x64/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/bin_libs/x86/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/bin_libs/x86/libusb0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/x86/libusb0.dll
--------------------------------------------------------------------------------
/bin_libs/libhamlib.so.2.1.1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/libhamlib.so.2.1.1
--------------------------------------------------------------------------------
/bin_libs/x64/libusb-1.0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/x64/libusb-1.0.dll
--------------------------------------------------------------------------------
/bin_libs/x86/libusb-1.0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/x86/libusb-1.0.dll
--------------------------------------------------------------------------------
/bin_libs/x64/libhamlib-2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/x64/libhamlib-2.dll
--------------------------------------------------------------------------------
/bin_libs/x86/libhamlib-2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/x86/libhamlib-2.dll
--------------------------------------------------------------------------------
/bin_libs/x64/libgcc_s_seh-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/x64/libgcc_s_seh-1.dll
--------------------------------------------------------------------------------
/bin_libs/x64/libwinpthread-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/x64/libwinpthread-1.dll
--------------------------------------------------------------------------------
/bin_libs/x86/libgcc_s_sjlj-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/x86/libgcc_s_sjlj-1.dll
--------------------------------------------------------------------------------
/bin_libs/x86/libwinpthread-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k5jae/HamLibSharp/HEAD/bin_libs/x86/libwinpthread-1.dll
--------------------------------------------------------------------------------
/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 | -->
4 |
5 |
6 |
--------------------------------------------------------------------------------
/IModeValue.cs:
--------------------------------------------------------------------------------
1 | //
2 | // IModeValue.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 |
25 | namespace HamLibSharp
26 | {
27 | public interface IModeValue
28 | {
29 | RigMode Modes { get; }
30 |
31 | int Value { get; }
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/IChannelList.cs:
--------------------------------------------------------------------------------
1 | //
2 | // IChannelList.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 |
25 | namespace HamLibSharp
26 | {
27 | public interface IChannelList
28 | {
29 | int Start { get; }
30 |
31 | int End { get; }
32 |
33 | RigMemoryChannel Type { get; }
34 |
35 | IChannelCapability MemCaps { get; }
36 | };
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/RigException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigException.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 |
25 | namespace HamLibSharp
26 | {
27 | public class RigException : Exception
28 | {
29 | public RigException () : base ()
30 | {
31 | }
32 |
33 | public RigException (string message) : base (message)
34 | {
35 | }
36 |
37 | public RigException (string message, Exception innerException) : base (message, innerException)
38 | {
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/IConfigurationParameter.cs:
--------------------------------------------------------------------------------
1 | //
2 | // IConfigurationParameter.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 |
25 | namespace HamLibSharp
26 | {
27 | /// Configuration parameter.
28 | public interface IConfigurationParameter
29 | {
30 | int Token { get; }
31 |
32 | string Name { get; }
33 |
34 | string Label { get; }
35 |
36 | string Tooltip { get; }
37 |
38 | string Default { get; }
39 |
40 | float Min { get; }
41 |
42 | float Max { get; }
43 |
44 | float Step { get; }
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/x86/ModeValue32.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ModeValue32.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x86
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal struct ModeValue32 : IModeValue
30 | {
31 | public RigMode Modes { get { return modes; } }
32 |
33 | public int Value { get { return val; } }
34 |
35 | public const int Any = 0;
36 |
37 | // Bit field of RIG_MODE's
38 | RigMode modes;
39 | // val
40 | int val;
41 | };
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/x64/ModeValue64.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ModeValue64.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x64
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal struct ModeValue64 : IModeValue
30 | {
31 | public RigMode Modes { get { return modes; } }
32 |
33 | public int Value { get { return (int)val; } }
34 |
35 | public const int Any = 0;
36 |
37 | // Bit field of RIG_MODE's
38 | RigMode modes;
39 | // val
40 | long val;
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/Utils/IntPtrExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // IntPtrExtensions.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This program is free software: you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as published by
11 | // the Free Software Foundation, either version 3 of the License, or
12 | // (at your option) any later version.
13 | //
14 | // This program is distributed in the hope that it will be useful,
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | // GNU Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public License
20 | // along with this program. If not, see .
21 | using System;
22 | using System.Runtime.InteropServices;
23 |
24 | namespace HamLibSharp
25 | {
26 | public static class IntPtrExtensions
27 | {
28 | public static IntPtr Increment (this IntPtr ptr, int cbSize)
29 | {
30 | return new IntPtr (ptr.ToInt64 () + cbSize);
31 | }
32 |
33 | public static IntPtr Increment (this IntPtr ptr)
34 | {
35 | return ptr.Increment (Marshal.SizeOf (typeof(T)));
36 | }
37 |
38 | public static T ElementAt (this IntPtr ptr, int index)
39 | {
40 | var offset = Marshal.SizeOf (typeof(T)) * index;
41 | var offsetPtr = ptr.Increment (offset);
42 | return (T)Marshal.PtrToStructure (offsetPtr, typeof(T));
43 | }
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/x86/ChannelList32.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ChannelList32.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x86
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal struct ChannelList32 : IChannelList
30 | {
31 | public int Start { get { return start; } }
32 |
33 | public int End { get { return end; } }
34 |
35 | public RigMemoryChannel Type { get { return type; } }
36 |
37 | public IChannelCapability MemCaps { get { return mem_caps; } }
38 |
39 | // Starting memory channel \b number
40 | int start;
41 | // Ending memory channel \b number
42 | int end;
43 | // Memory type. see chan_type_t
44 | RigMemoryChannel type;
45 | // Definition of attributes that can be stored/retrieved
46 | ChannelCapability32 mem_caps;
47 | };
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/x64/ChannelList64.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ChannelList64.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x64
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal struct ChannelList64 : IChannelList
30 | {
31 | public int Start { get { return start; } }
32 |
33 | public int End { get { return end; } }
34 |
35 | public RigMemoryChannel Type { get { return type; } }
36 |
37 | public IChannelCapability MemCaps { get { return mem_caps; } }
38 |
39 | // Starting memory channel \b number
40 | int start;
41 | // Ending memory channel \b number
42 | int end;
43 | // Memory type. see chan_type_t
44 | RigMemoryChannel type;
45 | // Definition of attributes that can be stored/retrieved
46 | ChannelCapability64 mem_caps;
47 | };
48 |
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/x64/NativeRig64.cs:
--------------------------------------------------------------------------------
1 | //
2 | // NativeRig64.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x64
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal class NativeRig64 : INativeRig
30 | {
31 | ///
32 | /// Pointer to rig capabilities (read only)
33 | ///
34 | public IntPtr caps;
35 | ///
36 | /// Rig state
37 | ///
38 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 1)]
39 | public RigStateNative64 state;
40 | ///
41 | /// Registered event callbacks
42 | ///
43 | public IntPtr callbacks;
44 |
45 | public IntPtr Caps { get { return caps; } }
46 | public IRigStateNative State { get { return state; } }
47 | public IntPtr Callbacks { get { return callbacks; } }
48 | };
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/x86/NativeRig32.cs:
--------------------------------------------------------------------------------
1 | //
2 | // NativeRig32.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x86
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal class NativeRig32 : INativeRig
30 | {
31 | ///
32 | /// Pointer to rig capabilities (read only)
33 | ///
34 | private IntPtr caps;
35 | ///
36 | /// Rig state
37 | ///
38 | //[MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 1)]
39 | private RigStateNative32 state;
40 | ///
41 | /// Registered event callbacks
42 | ///
43 | private IntPtr callbacks;
44 |
45 | public IntPtr Caps { get { return caps; } }
46 | public IRigStateNative State { get { return state; } }
47 | public IntPtr Callbacks { get { return callbacks; } }
48 | };
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/x64/NativeRig64v2.cs:
--------------------------------------------------------------------------------
1 | //
2 | // NativeRig64v2.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x64
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal class NativeRig64v2 : INativeRig
30 | {
31 | ///
32 | /// Pointer to rig capabilities (read only)
33 | ///
34 | public IntPtr caps;
35 | ///
36 | /// Rig state
37 | ///
38 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 1)]
39 | public RigStateNative64v2 state;
40 | ///
41 | /// Registered event callbacks
42 | ///
43 | public IntPtr callbacks;
44 |
45 | public IntPtr Caps { get { return caps; } }
46 | public IRigStateNative State { get { return state; } }
47 | public IntPtr Callbacks { get { return callbacks; } }
48 | };
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/x86/NativeRig32v2.cs:
--------------------------------------------------------------------------------
1 | //
2 | // NativeRig32v2.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x86
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal class NativeRig32v2 : INativeRig
30 | {
31 | ///
32 | /// Pointer to rig capabilities (read only)
33 | ///
34 | private IntPtr caps;
35 | ///
36 | /// Rig state
37 | ///
38 | //[MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 1)]
39 | private RigStateNative32v2 state;
40 | ///
41 | /// Registered event callbacks
42 | ///
43 | private IntPtr callbacks;
44 |
45 | public IntPtr Caps { get { return caps; } }
46 | public IRigStateNative State { get { return state; } }
47 | public IntPtr Callbacks { get { return callbacks; } }
48 | };
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/HamLibSharpTest/HamLibSharpTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {C75006E1-1D7A-4880-95F8-A968B4A71741}
7 | Exe
8 | HamLibSharpTest
9 | HamLibSharpTest
10 | v4.5.1
11 |
12 |
13 | true
14 | full
15 | false
16 | ..\build\Debug
17 | DEBUG;
18 | prompt
19 | 4
20 | true
21 |
22 |
23 | full
24 | true
25 | ..\build\Release
26 | prompt
27 | 4
28 | true
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | {878402CD-1AF7-443F-980F-861FF9E840CD}
41 | HamLibSharp
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Utils/TextNameAttribute.cs:
--------------------------------------------------------------------------------
1 | //
2 | // FieldDescription.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 | using System;
23 | using System.Reflection;
24 |
25 | namespace HamLibSharp.Utils
26 | {
27 | ///
28 | /// Allows us to add descriptions to interop members
29 | ///
30 | [AttributeUsage(AttributeTargets.Field)]
31 | public class TextNameAttribute : Attribute
32 | {
33 | ///
34 | /// The description
35 | ///
36 | public string Description { get; private set; }
37 |
38 | ///
39 | /// Field description
40 | ///
41 | public TextNameAttribute(string description)
42 | {
43 | Description = description;
44 | }
45 |
46 | ///
47 | /// String representation
48 | ///
49 | ///
50 | public override string ToString()
51 | {
52 | return Description;
53 | }
54 |
55 | public static string GetTextName(Enum value)
56 | {
57 | FieldInfo fi = value.GetType().GetField(value.ToString());
58 |
59 | TextNameAttribute[] attributes =
60 | (TextNameAttribute[])fi.GetCustomAttributes(typeof(TextNameAttribute), false);
61 |
62 | if (attributes != null && attributes.Length > 0)
63 | return attributes[0].Description;
64 | else
65 | return value.ToString();
66 | }
67 |
68 | }
69 |
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/RigVfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigVfo.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 |
25 | namespace HamLibSharp
26 | {
27 | public static class RigVfo
28 | {
29 | public const int None = 0;
30 | public const int TxFlag = (1 << 30);
31 |
32 | ///currVFO -- current "tunable channel"/VFO
33 | public const int Current = (1 << 29);
34 |
35 | ///MEM -- means Memory mode, to be used with set_vfo
36 | public const int Memory = (1 << 28);
37 |
38 | ///VFO -- means (last or any)VFO mode, with set_vfo
39 | public const int AnyVfo = (1 << 27);
40 |
41 | ///TX -- alias for split tx or uplink, of VFO_CURR
42 | public static int SplitTxUplink (int v)
43 | {
44 | return ((v) | TxFlag);
45 | }
46 |
47 | public static int Tx { get { return SplitTxUplink (Current); } }
48 |
49 | ///RX -- alias for split rx or downlink
50 | public const int SplitRxDownlink = Current;
51 |
52 | ///Main -- alias for MAIN
53 | public const int Main = (1 << 26);
54 |
55 | ///Sub -- alias for SUB
56 | public const int Sub = (1 << 25);
57 |
58 | public static int VfoNum (int n)
59 | {
60 | return (1 << (n));
61 | }
62 |
63 | ///VFOA -- VFO A
64 | public static int VfoA { get { return VfoNum (0); } }
65 |
66 | ///VFOB -- VFO B
67 | public static int VfoB { get { return VfoNum (1); } }
68 |
69 | ///VFOC -- VFO C
70 | public static int VfoC { get { return VfoNum (2); } }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/RigCaps/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Program.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This program is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU General Public License as published by
11 | // the Free Software Foundation; either version 2 of the License, or
12 | // (at your option) any later version.
13 | //
14 | // This program is distributed in the hope that it will be useful,
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | // GNU General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU General Public License
20 | // along with this program; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System.Reflection;
24 | using System.Runtime.CompilerServices;
25 |
26 | // Information about this assembly is defined by the following attributes.
27 | // Change them to the values specific to your project.
28 |
29 | [assembly: AssemblyTitle ("RigCaps")]
30 | [assembly: AssemblyDescription ("Test of HamLibSharp")]
31 | [assembly: AssemblyConfiguration ("")]
32 | [assembly: AssemblyCompany ("Jae Stutzman")]
33 | [assembly: AssemblyProduct ("RigCaps")]
34 | [assembly: AssemblyCopyright ("Copyright © 2016 Jae Stutzman")]
35 | [assembly: AssemblyTrademark ("")]
36 | [assembly: AssemblyCulture ("")]
37 | [assembly: AssemblyMetadata ("License", "This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. GPL v2")]
38 |
39 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
40 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
41 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
42 |
43 | [assembly: AssemblyVersion ("1.0.*")]
44 |
45 | // The following attributes are used to specify the signing key for the assembly,
46 | // if desired. See the Mono documentation for more information about signing.
47 |
48 | //[assembly: AssemblyDelaySign(false)]
49 | //[assembly: AssemblyKeyFile("")]
50 |
51 |
--------------------------------------------------------------------------------
/HamLibSharpTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // AssemblyInfo.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System.Reflection;
24 | using System.Runtime.CompilerServices;
25 |
26 | // Information about this assembly is defined by the following attributes.
27 | // Change them to the values specific to your project.
28 |
29 | [assembly: AssemblyTitle ("HamLibSharpTest")]
30 | [assembly: AssemblyDescription ("Test of HamLibSharp")]
31 | [assembly: AssemblyConfiguration ("")]
32 | [assembly: AssemblyCompany ("Jae Stutzman")]
33 | [assembly: AssemblyProduct ("HamLibSharpTest")]
34 | [assembly: AssemblyCopyright ("Copyright © 2016 Jae Stutzman")]
35 | [assembly: AssemblyTrademark ("")]
36 | [assembly: AssemblyCulture ("")]
37 | [assembly: AssemblyMetadata ("License", "This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. LGPL v2.1")]
38 |
39 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
40 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
41 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
42 |
43 | [assembly: AssemblyVersion ("1.0.*")]
44 |
45 | // The following attributes are used to specify the signing key for the assembly,
46 | // if desired. See the Mono documentation for more information about signing.
47 |
48 | //[assembly: AssemblyDelaySign(false)]
49 | //[assembly: AssemblyKeyFile("")]
50 |
51 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // AssemblyInfo.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System.Reflection;
24 | using System.Runtime.CompilerServices;
25 |
26 | // Information about this assembly is defined by the following attributes.
27 | // Change them to the values specific to your project.
28 |
29 | [assembly: AssemblyTitle ("HamLibSharp")]
30 | [assembly: AssemblyDescription ("Binding for the HamLib Amateur Radio control library")]
31 | [assembly: AssemblyConfiguration ("")]
32 | [assembly: AssemblyCompany ("Jae Stutzman")]
33 | [assembly: AssemblyProduct ("HamLibSharp")]
34 | [assembly: AssemblyCopyright ("Copyright © 2016 Jae Stutzman")]
35 | [assembly: AssemblyTrademark ("")]
36 | [assembly: AssemblyCulture ("")]
37 | [assembly: AssemblyMetadata ("License", "This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. LGPL v2.1")]
38 |
39 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
40 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
41 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
42 |
43 | [assembly: AssemblyVersion ("3.1.*")]
44 |
45 | // The following attributes are used to specify the signing key for the assembly,
46 | // if desired. See the Mono documentation for more information about signing.
47 |
48 | //[assembly: AssemblyDelaySign(false)]
49 | //[assembly: AssemblyKeyFile("")]
50 |
51 |
--------------------------------------------------------------------------------
/x86/ConfigurationParameter32.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ConfigurationParameter32.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x86
27 | {
28 | /// Configuration parameter structure.
29 | [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
30 | internal class ConfigurationParameter32 : IConfigurationParameter
31 | {
32 | public int Token { get { return token; } }
33 |
34 | public string Name { get { return name; } }
35 |
36 | public string Label { get { return label; } }
37 |
38 | public string Tooltip { get { return tooltip; } }
39 |
40 | public string Default { get { return dflt; } }
41 |
42 | public float Min { get { return min; } }
43 |
44 | public float Max { get { return max; } }
45 |
46 | public float Step { get { return step; } }
47 |
48 | /*!< Conf param token ID */
49 | int token;
50 | /*!< Param name, no spaces allowed */
51 | [MarshalAs (UnmanagedType.LPStr)]
52 | string name;
53 | /*!< Human readable label */
54 | [MarshalAs (UnmanagedType.LPStr)]
55 | string label;
56 | /*!< Hint on the parameter */
57 | [MarshalAs (UnmanagedType.LPStr)]
58 | string tooltip;
59 | /*!< Default value */
60 | [MarshalAs (UnmanagedType.LPStr)]
61 | string dflt;
62 | /*!< Type of the parameter */
63 | RigConf type;
64 | /*!< */
65 | //[MarshalAs (UnmanagedType.Struct)]
66 | //paramU u;
67 | /*!< Minimum value */
68 | float min;
69 | /*!< Maximum value */
70 | float max;
71 | /*!< Step */
72 | float step;
73 | /*!< Numeric type */
74 | }
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/x64/ConfigurationParameter64.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ConfigurationParameter64.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x64
27 | {
28 | /// Configuration parameter structure.
29 | [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
30 | internal class ConfigurationParameter64 : IConfigurationParameter
31 | {
32 | public int Token { get { return (int)token; } }
33 |
34 | public string Name { get { return name; } }
35 |
36 | public string Label { get { return label; } }
37 |
38 | public string Tooltip { get { return tooltip; } }
39 |
40 | public string Default { get { return dflt; } }
41 |
42 | public float Min { get { return min; } }
43 |
44 | public float Max { get { return max; } }
45 |
46 | public float Step { get { return step; } }
47 |
48 | /*!< Conf param token ID */
49 | long token;
50 | /*!< Param name, no spaces allowed */
51 | [MarshalAs (UnmanagedType.LPStr)]
52 | string name;
53 | /*!< Human readable label */
54 | [MarshalAs (UnmanagedType.LPStr)]
55 | string label;
56 | /*!< Hint on the parameter */
57 | [MarshalAs (UnmanagedType.LPStr)]
58 | string tooltip;
59 | /*!< Default value */
60 | [MarshalAs (UnmanagedType.LPStr)]
61 | string dflt;
62 | /*!< Type of the parameter */
63 | RigConf type;
64 | /*!< */
65 | //[MarshalAs (UnmanagedType.Struct)]
66 | //paramU u;
67 | /*!< Minimum value */
68 | float min;
69 | /*!< Maximum value */
70 | float max;
71 | /*!< Step */
72 | float step;
73 | /*!< Numeric type */
74 | }
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # HamLibSharp
3 | Mono/.NET Binding for the Ham Radio Control Libraries (https://github.com/N0NB/hamlib)
4 |
5 | The goal of this binding is to support desktop platforms HamLib supports. Currently tested with Linux (Ubuntu 16.04) on both 64 and 32 bit architectures and Windows as a 32-bit process.
6 |
7 | This binding is a work-in-progress. It targets HamLib 1.2, 3.0.1 and 3.1(git). Native structs are abstracted by interfaces, which allows client code to "just work"
8 |
9 | ###What has been tested
10 | - Rig VFO Frequency adjustments (both read and write)
11 | - PTT keying
12 | - Rig Mode adjustments (both read and write)
13 |
14 | ###How it works
15 | This binding uses .NET P/Invoke functionality to make calls into C libraries. Data structures from the C library have been recreated in the binding and data is marshaled from native memory into managed memory. The native library is not hard linked and the .so or .dll must be in the path for this binding to locate it at runtime. The project file will copy files from bin_libs into the output directory.
16 |
17 | ###What's unique
18 | 1. Similar to the C++ binding, generally any reported errors from HamLib will be thrown as RigException to client code.
19 | 2. The binding has its own polling loop. To use this feature, the client code must call Rig.Start() after a successful Rig.Open(...).
20 | - This binding will automatically poll for common values from Rig. Currently it polls for Frequency, Mode, and PTT. The polling interval is defined when the Rig class is constructed. The client application can use the Rig public properties to get current values.
21 | - For "set" type functions, the binding will add the call to the TaskQueue and return immediately. For GUI apps, this means that blocking is kept to a minimum. If Rig.Start() is not called, the functions will block until HamLib returns. (WORK IN PROGRESS: Not all set functions take advantage of the TaskQueue)
22 |
23 | ###Getting Started:
24 | 1. Start by cloning the git repository to a directory of your choice
25 | 2. Use your OS distribution of hamlib, or place the libhamlib.so.2 into the ./bin_libs or the Windows libhamlib-2.dll (and all dependancies) into the ./bin_libs/x86 directory (32-bit library)
26 | 3. Use MonoDevelop or xbuild to build the .sln file
27 | 4. Run the test programs which should be located in the ./build/(CONF)/ directory.
28 |
29 | Note: You may need to rename the HamLib .so file if you copy it from HamLib build.
30 |
31 | More description and HOWTO to follow.
32 |
--------------------------------------------------------------------------------
/IChannelCapability.cs:
--------------------------------------------------------------------------------
1 | //
2 | // IChannelCapability.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 |
25 | namespace HamLibSharp
26 | {
27 | // Channel capability definition
28 | //
29 | // Definition of the attributes that can be stored/retrieved in/from memory
30 | public interface IChannelCapability
31 | {
32 | // Bank number
33 | bool BankNumber { get; }
34 | // VFO
35 | bool Vfo { get; }
36 | // Selected antenna
37 | bool Antenna { get; }
38 | // Receive frequency
39 | bool RXFrequency { get; }
40 | // Receive mode
41 | bool RXMode { get; }
42 | // Receive passband width associated with mode
43 | bool RXWidth { get; }
44 | // Transmit frequency
45 | bool TXFrequency { get; }
46 | // Transmit mode
47 | bool TXMode { get; }
48 | // Transmit passband width associated with mode
49 |
50 | bool TXWidth { get; }
51 | // Split mode
52 | bool Split { get; }
53 | // Split transmit VFO
54 | bool TXVfo { get; }
55 | // Repeater shift
56 | bool RepeaterShift { get; }
57 | // Repeater offset
58 | bool RepeaterOffset { get; }
59 | // Tuning step
60 | bool TuningStep { get; }
61 | // RIT
62 | bool Rit { get; }
63 | // XIT
64 | bool Xit { get; }
65 |
66 | uint Functions { get; }
67 |
68 | uint Levels { get; }
69 |
70 | // CTCSS tone
71 | bool CtcssTone { get; }
72 | // CTCSS squelch tone
73 | bool CtcssSquelch { get; }
74 | // DCS code
75 | bool DcsCode { get; }
76 | // DCS squelch code
77 | bool DcsSquelch { get; }
78 | // Scan group
79 | bool ScanGroup { get; }
80 | // Channel flags
81 | bool ChannelFlags { get; }
82 | // Name
83 | bool ChannelName { get; }
84 | // Extension level value list
85 | bool ExtensionLevels { get; }
86 | }
87 |
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/IRigStateNative.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigStateNative.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 |
27 | namespace HamLibSharp
28 | {
29 | // TODO: Primary interest is to get the vfo_list and mode_list. Everything else untested.
30 |
31 | internal interface IRigStateNative
32 | {
33 | HamLibPortNative[] Ptt_dcd_ports { get; }
34 |
35 | double Vfo_comp { get; }
36 |
37 | int Itu_region { get; }
38 |
39 | FrequencyRange[] Rx_range_list { get; }
40 |
41 | FrequencyRange[] Tx_range_list { get; }
42 |
43 | IList Tuning_steps { get; }
44 |
45 | IList Filters { get; }
46 |
47 | CalibrationTable Str_cal { get; }
48 |
49 | IList Chan_list { get; }
50 |
51 | int Max_rit { get; }
52 |
53 | int Max_xit { get; }
54 |
55 | int Max_ifshift { get; }
56 |
57 | RigAnnounce Announces { get; }
58 |
59 | int[] Preamp { get; }
60 |
61 | int[] Attenuator { get; }
62 |
63 | uint Has_get_func { get; }
64 |
65 | uint Has_set_func { get; }
66 |
67 | uint Has_get_level { get; }
68 |
69 | uint Has_set_level { get; }
70 |
71 | uint Has_get_parm { get; }
72 |
73 | uint Has_set_parm { get; }
74 |
75 | Granularity[] Level_gran { get; }
76 |
77 | Granularity[] Parm_gran { get; }
78 |
79 | int Hold_decode { get; }
80 |
81 | int Current_vfo { get; }
82 |
83 | int Vfo_list { get; }
84 |
85 | int Comm_state { get; }
86 |
87 | IntPtr Priv { get; }
88 |
89 | IntPtr Obj { get; }
90 |
91 | int Transceive { get; }
92 |
93 | int Poll_interval { get; }
94 |
95 | double Current_freq { get; }
96 |
97 | RigMode Current_mode { get; }
98 |
99 | int Current_width { get; }
100 |
101 | int Tx_vfo { get; }
102 |
103 | RigMode Mode_list { get; }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/HamLibSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HamLibSharp", "HamLibSharp.csproj", "{878402CD-1AF7-443F-980F-861FF9E840CD}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HamLibSharpTest", "HamLibSharpTest\HamLibSharpTest.csproj", "{C75006E1-1D7A-4880-95F8-A968B4A71741}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RigCaps", "RigCaps\RigCaps.csproj", "{04C50C92-9170-4BF9-AC4C-3A8264BF7762}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {04C50C92-9170-4BF9-AC4C-3A8264BF7762}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {04C50C92-9170-4BF9-AC4C-3A8264BF7762}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {04C50C92-9170-4BF9-AC4C-3A8264BF7762}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {04C50C92-9170-4BF9-AC4C-3A8264BF7762}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {878402CD-1AF7-443F-980F-861FF9E840CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {878402CD-1AF7-443F-980F-861FF9E840CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {878402CD-1AF7-443F-980F-861FF9E840CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {878402CD-1AF7-443F-980F-861FF9E840CD}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {C75006E1-1D7A-4880-95F8-A968B4A71741}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {C75006E1-1D7A-4880-95F8-A968B4A71741}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {C75006E1-1D7A-4880-95F8-A968B4A71741}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {C75006E1-1D7A-4880-95F8-A968B4A71741}.Release|Any CPU.Build.0 = Release|Any CPU
28 | EndGlobalSection
29 | GlobalSection(MonoDevelopProperties) = preSolution
30 | Policies = $0
31 | $0.StandardHeader = $1
32 | $1.Text = @\n ${FileName}\n \n Author:\n ${AuthorName} <${AuthorEmail}>\n\n Copyright (c) ${Year} ${CopyrightHolder}\n\n This library is free software; you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as\n published by the Free Software Foundation; either version 2.1 of the\n License, or (at your option) any later version.\n\n This library is distributed in the hope that it will be useful, but\n WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with this library; if not, write to the Free Software\n Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 | $1.IncludeInNewFiles = True
34 | EndGlobalSection
35 | EndGlobal
36 |
--------------------------------------------------------------------------------
/RigCaps/RigCaps.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {04C50C92-9170-4BF9-AC4C-3A8264BF7762}
7 | Exe
8 | RigCaps
9 | RigCaps
10 | v4.5.1
11 |
12 |
13 | true
14 | full
15 | false
16 | ..\build\Debug
17 | DEBUG;
18 | prompt
19 | 4
20 | true
21 |
22 |
23 | full
24 | true
25 | ..\build\Release
26 | prompt
27 | 4
28 | true
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | {878402CD-1AF7-443F-980F-861FF9E840CD}
41 | HamLibSharp
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/Utils/CastedList.cs:
--------------------------------------------------------------------------------
1 | //
2 | // CastedList.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections;
25 | using System.Collections.Generic;
26 |
27 | namespace HamLibSharp
28 | {
29 | // Note this class comes from: http://stackoverflow.com/a/30662440
30 | public class CastedList : IList
31 | {
32 | public IList BaseList;
33 |
34 | public CastedList(IList baseList)
35 | {
36 | BaseList = baseList;
37 | }
38 |
39 | // IEnumerable
40 | IEnumerator IEnumerable.GetEnumerator() { return BaseList.GetEnumerator(); }
41 |
42 | // IEnumerable<>
43 | public IEnumerator GetEnumerator() { return new CastedEnumerator(BaseList.GetEnumerator()); }
44 |
45 | // ICollection
46 | public int Count { get { return BaseList.Count; } }
47 | public bool IsReadOnly { get { return BaseList.IsReadOnly; } }
48 | public void Add(TTo item) { BaseList.Add((TFrom)(object)item); }
49 | public void Clear() { BaseList.Clear(); }
50 | public bool Contains(TTo item) { return BaseList.Contains((TFrom)(object)item); }
51 | public void CopyTo(TTo[] array, int arrayIndex) { BaseList.CopyTo((TFrom[])(object)array, arrayIndex); }
52 | public bool Remove(TTo item) { return BaseList.Remove((TFrom)(object)item); }
53 |
54 | // IList
55 | public TTo this[int index]
56 | {
57 | get { return (TTo)(object)BaseList[index]; }
58 | set { BaseList[index] = (TFrom)(object)value; }
59 | }
60 |
61 | public int IndexOf(TTo item) { return BaseList.IndexOf((TFrom)(object)item); }
62 | public void Insert(int index, TTo item) { BaseList.Insert(index, (TFrom)(object)item); }
63 | public void RemoveAt(int index) { BaseList.RemoveAt(index); }
64 | }
65 |
66 | public class CastedEnumerator : IEnumerator
67 | {
68 | public IEnumerator BaseEnumerator;
69 |
70 | public CastedEnumerator(IEnumerator baseEnumerator)
71 | {
72 | BaseEnumerator = baseEnumerator;
73 | }
74 |
75 | // IDisposable
76 | public void Dispose() { BaseEnumerator.Dispose(); }
77 |
78 | // IEnumerator
79 | object IEnumerator.Current { get { return BaseEnumerator.Current; } }
80 | public bool MoveNext() { return BaseEnumerator.MoveNext(); }
81 | public void Reset() { BaseEnumerator.Reset(); }
82 |
83 | // IEnumerator<>
84 | public TTo Current { get { return (TTo)(object)BaseEnumerator.Current; } }
85 | }
86 |
87 | public static class ListExtensions
88 | {
89 | public static IList CastList(this IList list)
90 | {
91 | return new CastedList(list);
92 | }
93 | }
94 | }
95 |
96 |
--------------------------------------------------------------------------------
/x86/ChannelCapability32.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ChannelCapability32.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x86
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal struct ChannelCapability32: IChannelCapability
30 | {
31 | private short raw0;
32 |
33 | // Bank number
34 | public bool BankNumber { get { return ((byte)((raw0 >> 0) & 0x01)) != 0; } }
35 | // VFO
36 | public bool Vfo{ get { return ((byte)((raw0 >> 1) & 0x01)) != 0; } }
37 | // Selected antenna
38 | public bool Antenna{ get { return ((byte)((raw0 >> 2) & 0x01)) != 0; } }
39 | // Receive frequency
40 | public bool RXFrequency{ get { return ((byte)((raw0 >> 3) & 0x01)) != 0; } }
41 | // Receive mode
42 | public bool RXMode{ get { return ((byte)((raw0 >> 4) & 0x01)) != 0; } }
43 | // Receive passband width associated with mode
44 | public bool RXWidth{ get { return ((byte)((raw0 >> 5) & 0x01)) != 0; } }
45 | // Transmit frequency
46 | public bool TXFrequency{ get { return ((byte)((raw0 >> 6) & 0x01)) != 0; } }
47 | // Transmit mode
48 | public bool TXMode{ get { return ((byte)((raw0 >> 7) & 0x01)) != 0; } }
49 | // Transmit passband width associated with mode
50 |
51 | public bool TXWidth{ get { return ((byte)((raw0 >> 8) & 0x01)) != 0; } }
52 | // Split mode
53 | public bool Split{ get { return ((byte)((raw0 >> 9) & 0x01)) != 0; } }
54 | // Split transmit VFO
55 | public bool TXVfo{ get { return ((byte)((raw0 >> 10) & 0x01)) != 0; } }
56 | // Repeater shift
57 | public bool RepeaterShift{ get { return ((byte)((raw0 >> 11) & 0x01)) != 0; } }
58 | // Repeater offset
59 | public bool RepeaterOffset{ get { return ((byte)((raw0 >> 12) & 0x01)) != 0; } }
60 | // Tuning step
61 | public bool TuningStep{ get { return ((byte)((raw0 >> 13) & 0x01)) != 0; } }
62 | // RIT
63 | public bool Rit{ get { return ((byte)((raw0 >> 14) & 0x01)) != 0; } }
64 | // XIT
65 | public bool Xit{ get { return ((byte)((raw0 >> 15) & 0x01)) != 0; } }
66 |
67 | // Function status
68 | uint funcs;
69 | // Level values
70 | uint levels;
71 |
72 | public uint Functions { get { return funcs; } }
73 |
74 | public uint Levels { get { return levels; } }
75 |
76 | private short raw2;
77 |
78 | // CTCSS tone
79 | public bool CtcssTone { get { return ((byte)((raw2 >> 0) & 0x01)) != 0; } }
80 | // CTCSS squelch tone
81 | public bool CtcssSquelch{ get { return ((byte)((raw2 >> 1) & 0x01)) != 0; } }
82 | // DCS code
83 | public bool DcsCode{ get { return ((byte)((raw2 >> 2) & 0x01)) != 0; } }
84 | // DCS squelch code
85 | public bool DcsSquelch{ get { return ((byte)((raw2 >> 3) & 0x01)) != 0; } }
86 | // Scan group
87 | public bool ScanGroup{ get { return ((byte)((raw2 >> 4) & 0x01)) != 0; } }
88 | // Channel flags
89 | public bool ChannelFlags{ get { return ((byte)((raw2 >> 5) & 0x01)) != 0; } }
90 | // Name
91 | public bool ChannelName{ get { return ((byte)((raw2 >> 6) & 0x01)) != 0; } }
92 | // Extension level value list
93 | public bool ExtensionLevels{ get { return ((byte)((raw2 >> 7) & 0x01)) != 0; } }
94 | }
95 | }
96 |
97 |
--------------------------------------------------------------------------------
/x64/ChannelCapability64.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ChannelCapability64.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp.x64
27 | {
28 | [StructLayout (LayoutKind.Sequential)]
29 | internal struct ChannelCapability64: IChannelCapability
30 | {
31 | private short raw0;
32 |
33 | // Bank number
34 | public bool BankNumber { get { return ((byte)((raw0 >> 0) & 0x01)) != 0; } }
35 | // VFO
36 | public bool Vfo{ get { return ((byte)((raw0 >> 1) & 0x01)) != 0; } }
37 | // Selected antenna
38 | public bool Antenna{ get { return ((byte)((raw0 >> 2) & 0x01)) != 0; } }
39 | // Receive frequency
40 | public bool RXFrequency{ get { return ((byte)((raw0 >> 3) & 0x01)) != 0; } }
41 | // Receive mode
42 | public bool RXMode{ get { return ((byte)((raw0 >> 4) & 0x01)) != 0; } }
43 | // Receive passband width associated with mode
44 | public bool RXWidth{ get { return ((byte)((raw0 >> 5) & 0x01)) != 0; } }
45 | // Transmit frequency
46 | public bool TXFrequency{ get { return ((byte)((raw0 >> 6) & 0x01)) != 0; } }
47 | // Transmit mode
48 | public bool TXMode{ get { return ((byte)((raw0 >> 7) & 0x01)) != 0; } }
49 | // Transmit passband width associated with mode
50 |
51 | public bool TXWidth{ get { return ((byte)((raw0 >> 8) & 0x01)) != 0; } }
52 | // Split mode
53 | public bool Split{ get { return ((byte)((raw0 >> 9) & 0x01)) != 0; } }
54 | // Split transmit VFO
55 | public bool TXVfo{ get { return ((byte)((raw0 >> 10) & 0x01)) != 0; } }
56 | // Repeater shift
57 | public bool RepeaterShift{ get { return ((byte)((raw0 >> 11) & 0x01)) != 0; } }
58 | // Repeater offset
59 | public bool RepeaterOffset{ get { return ((byte)((raw0 >> 12) & 0x01)) != 0; } }
60 | // Tuning step
61 | public bool TuningStep{ get { return ((byte)((raw0 >> 13) & 0x01)) != 0; } }
62 | // RIT
63 | public bool Rit{ get { return ((byte)((raw0 >> 14) & 0x01)) != 0; } }
64 | // XIT
65 | public bool Xit{ get { return ((byte)((raw0 >> 15) & 0x01)) != 0; } }
66 |
67 | // Function status
68 | ulong funcs;
69 | // Level values
70 | ulong levels;
71 |
72 | public uint Functions { get { return (uint)funcs; } }
73 |
74 | public uint Levels { get { return (uint)levels; } }
75 |
76 |
77 | private short raw2;
78 |
79 | // CTCSS tone
80 | public bool CtcssTone { get { return ((byte)((raw2 >> 0) & 0x01)) != 0; } }
81 | // CTCSS squelch tone
82 | public bool CtcssSquelch{ get { return ((byte)((raw2 >> 1) & 0x01)) != 0; } }
83 | // DCS code
84 | public bool DcsCode{ get { return ((byte)((raw2 >> 2) & 0x01)) != 0; } }
85 | // DCS squelch code
86 | public bool DcsSquelch{ get { return ((byte)((raw2 >> 3) & 0x01)) != 0; } }
87 | // Scan group
88 | public bool ScanGroup{ get { return ((byte)((raw2 >> 4) & 0x01)) != 0; } }
89 | // Channel flags
90 | public bool ChannelFlags{ get { return ((byte)((raw2 >> 5) & 0x01)) != 0; } }
91 | // Name
92 | public bool ChannelName{ get { return ((byte)((raw2 >> 6) & 0x01)) != 0; } }
93 | // Extension level value list
94 | public bool ExtensionLevels{ get { return ((byte)((raw2 >> 7) & 0x01)) != 0; } }
95 | }
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/HamLibSharpTest/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Program.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 | using HamLibSharp;
27 |
28 | namespace HamLibSharpTest
29 | {
30 | class MainClass
31 | {
32 | public static void Main (string[] args)
33 | {
34 | //var rigName = "Dummy";
35 | //var port = string.Empty;
36 |
37 | //var rigName = "FT-857";
38 | //var port = "/dev/ttyUSB0";
39 |
40 | var rigName = "PiHPSDR";
41 | var port = "127.0.0.1:19090";
42 |
43 | Console.WriteLine("HamLib Native Library Version: {0}", HamLib.NativeVersion);
44 | Console.WriteLine("HamLib Managed Library Version: {0}", HamLib.ManagedVersion);
45 |
46 | Console.WriteLine ();
47 | Console.WriteLine ("WARNING: This will PTT your RIG!! Ensure proper dummy load");
48 | Console.WriteLine ("Press Enter to continue or CTRL+C to exit");
49 | Console.ReadLine ();
50 |
51 | Console.WriteLine ("Attempting to open: {0} at port: {1}", rigName, port);
52 |
53 | //This will output to console hamlib traces
54 | //HamLib.SetDebugLevel (RigDebugLevel.Trace);
55 |
56 | Rig rig = null;
57 | try {
58 | rig = new Rig (rigName);
59 | rig.Open (port);
60 | } catch (RigException e) {
61 | Console.WriteLine ("Unable to Open Rig: {0}", e.Message);
62 | return;
63 | }
64 |
65 |
66 | var freqHz = 28350125;
67 | Console.WriteLine ("Set Frequency to: {0}", Rig.FrequencyToString (freqHz));
68 | rig.SetFrequency (freqHz);
69 |
70 | Console.WriteLine ("Read Frequency is: {0}", Rig.FrequencyToString (rig.GetFrequency ()));
71 |
72 | Console.WriteLine ("Attempting to PTT Rig for 1 Sec");
73 | //rig.SetPtt (PttMode.On);
74 |
75 | System.Threading.Thread.Sleep (1000);
76 | Console.WriteLine(rig.GetPtt ());
77 |
78 | Console.WriteLine ("PTT OFF");
79 | rig.SetPtt (PttMode.Off);
80 |
81 | rig.SetLevel (RigLevel.Agc, (int)RigAgcLevel.Off);
82 |
83 | System.Threading.Thread.Sleep (1000);
84 |
85 | int level;
86 | rig.GetLevel (RigLevel.Agc, out level);
87 | Console.WriteLine ("AGC Level: {0}", level);
88 |
89 | rig.SetLevel (RigLevel.Agc, (int)RigAgcLevel.Superfast);
90 | System.Threading.Thread.Sleep (1000);
91 | rig.GetLevel (RigLevel.Agc, out level);
92 | Console.WriteLine ("AGC Level: {0}", level);
93 |
94 | rig.SetLevel (RigLevel.Agc, (int)RigAgcLevel.Fast);
95 | System.Threading.Thread.Sleep (1000);
96 | rig.GetLevel (RigLevel.Agc, out level);
97 | Console.WriteLine ("AGC Level: {0}", level);
98 |
99 |
100 | rig.SetLevel (RigLevel.Agc, (int)RigAgcLevel.Medium);
101 | System.Threading.Thread.Sleep (1000);
102 | rig.GetLevel (RigLevel.Agc, out level);
103 | Console.WriteLine ("AGC Level: {0}", level);
104 |
105 | rig.SetLevel (RigLevel.Agc, (int)RigAgcLevel.Slow);
106 | System.Threading.Thread.Sleep (1000);
107 | rig.GetLevel (RigLevel.Agc, out level);
108 | Console.WriteLine ("AGC Level: {0}", level);
109 |
110 |
111 | while (true) {
112 | Console.WriteLine ("Frequency is: {0}", Rig.FrequencyToString (rig.GetFrequency ()));
113 | System.Threading.Thread.Sleep (1000);
114 | }
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/Structs.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Structs.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp
27 | {
28 | [StructLayout (LayoutKind.Explicit)]
29 | public struct Value
30 | {
31 | // Signed integer
32 | [FieldOffset (0)]
33 | int i;
34 | // Single precision float
35 | [FieldOffset (0)]
36 | float f;
37 | // Pointer to char string
38 | [MarshalAs (UnmanagedType.LPStr)]
39 | [FieldOffset (0)]
40 | string s;
41 | // Pointer to constant char string
42 | [MarshalAs (UnmanagedType.LPStr)]
43 | [FieldOffset (0)]
44 | string cs;
45 | }
46 |
47 | /// Numeric type
48 | [StructLayout (LayoutKind.Sequential)]
49 | struct paramN
50 | {
51 | /// Minimum value
52 | float min;
53 | /// Maximum value
54 | float max;
55 | /// Step
56 | float step;
57 | }
58 |
59 | /// Combo type
60 | [StructLayout (LayoutKind.Sequential)]
61 | struct paramC
62 | {
63 | /// Combo list
64 | [MarshalAs (UnmanagedType.LPStr)]
65 | string combostr;
66 | }
67 |
68 | [StructLayout (LayoutKind.Explicit)]
69 | struct paramU
70 | {
71 | [FieldOffset (0)]
72 | [MarshalAs (UnmanagedType.Struct)]
73 | paramN n;
74 | [FieldOffset (0)]
75 | [MarshalAs (UnmanagedType.Struct)]
76 | paramC c;
77 | }
78 |
79 | // TODO: ConfigurationParameter still needs to attention due to C unions ///
80 |
81 | // TODO: the value_t union makes this difficult
82 | [StructLayout (LayoutKind.Sequential)]
83 | public struct Granularity
84 | {
85 | // Minimum value
86 | IntPtr min;
87 | // Maximum value
88 | IntPtr max;
89 | // Step
90 | IntPtr step;
91 | }
92 |
93 | // Frequency range
94 | // Put together a group of this struct in an array to define
95 | // what frequencies your rig has access to.
96 | [StructLayout (LayoutKind.Sequential)]
97 | public struct FrequencyRange
98 | {
99 | public double Start { get { return start; } }
100 |
101 | public double End { get { return end; } }
102 |
103 | public RigMode Modes { get { return modes; } }
104 |
105 | public int LowPower { get { return low_power; } }
106 |
107 | public int HighPower { get { return high_power; } }
108 |
109 | public int Vfo { get { return vfo; } }
110 |
111 | public int Antenna { get { return ant; } }
112 |
113 | // Start frequency
114 | double start;
115 | // End frequency
116 | double end;
117 | // Bit field of RIG_MODE's
118 | RigMode modes;
119 | // Lower RF power in mW, -1 for no power (ie. rx list)
120 | int low_power;
121 | // Higher RF power in mW, -1 for no power (ie. rx list)
122 | int high_power;
123 | // VFO list equipped with this range
124 | int vfo;
125 | // Antenna list equipped with this range, 0 means all
126 | int ant;
127 | }
128 |
129 | // Calibration table struct
130 | [StructLayout (LayoutKind.Sequential)]
131 | public class CalibrationTable
132 | {
133 | [StructLayout (LayoutKind.Sequential)]
134 | public struct TableDef
135 | {
136 | // raw (A/D) value, as returned by \a RIG_LEVEL_RAWSTR
137 | int raw;
138 | // associated value, basically the measured dB value
139 | int val;
140 | }
141 |
142 | // number of plots in the table
143 | int size;
144 |
145 | // table of plots
146 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.MAX_CAL_LENGTH)]
147 | TableDef[] table = new CalibrationTable.TableDef[Rig.MAX_CAL_LENGTH];
148 | };
149 | }
150 |
--------------------------------------------------------------------------------
/Utils/Library.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Library.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using System;
28 | using System.IO;
29 | using System.Xml;
30 | using System.Reflection;
31 | using System.Runtime.InteropServices;
32 |
33 | namespace HamLibSharp.Utils
34 | {
35 | internal class Library
36 | {
37 | internal static string Copyright { get; private set; }
38 |
39 | internal static string License { get; private set; }
40 |
41 | internal static Version Version { get; private set; }
42 |
43 | private Library ()
44 | {
45 | }
46 |
47 | static Library ()
48 | {
49 | var assembly = Assembly.GetExecutingAssembly ();
50 | var copyrightAttributes = assembly.GetCustomAttributes (typeof(AssemblyCopyrightAttribute), false);
51 |
52 | //var attribute = null;
53 | if (copyrightAttributes.Length > 0) {
54 | var attribute = copyrightAttributes [0] as AssemblyCopyrightAttribute;
55 | Copyright = attribute.Copyright;
56 | }
57 |
58 | var metadataAttributes = assembly.GetCustomAttributes (typeof(AssemblyMetadataAttribute), false);
59 |
60 | //var attribute = null;
61 | if (metadataAttributes.Length > 0) {
62 | var attribute = metadataAttributes [0] as AssemblyMetadataAttribute;
63 | if (attribute.Key == "License") {
64 | License = attribute.Value;
65 | }
66 | }
67 |
68 | Version = assembly.GetName ().Version;
69 | }
70 |
71 | private static string GetDllConfig (bool x64)
72 | {
73 | string dllDirectory = string.Empty;
74 |
75 | string codeBase = Assembly.GetExecutingAssembly ().CodeBase;
76 | UriBuilder uri = new UriBuilder (codeBase);
77 | string path = Uri.UnescapeDataString (uri.Path);
78 | XmlTextReader reader = new XmlTextReader (path + ".config");
79 | try {
80 | while (reader.Read ()) {
81 | // Do some work here on the data.
82 | //Console.WriteLine(reader.Name);
83 |
84 | if (reader.Name == "dllwinpath") {
85 | while (reader.MoveToNextAttribute ()) { // Read the attributes.
86 | //Console.Write(" " + reader.Name + "='" + reader.Value + "'");
87 | switch (reader.Name) {
88 | case "x64":
89 | if (x64) {
90 | dllDirectory = reader.Value;
91 | }
92 | break;
93 | case "x86":
94 | if (!x64) {
95 | dllDirectory = reader.Value;
96 | }
97 | break;
98 | }
99 | }
100 | //Console.WriteLine();
101 | }
102 | }
103 | } catch (Exception) {}
104 |
105 | return dllDirectory;
106 | }
107 |
108 | internal static bool LoadLibrary (string dllName)
109 | {
110 | if (System.Environment.OSVersion.Platform != PlatformID.MacOSX && System.Environment.OSVersion.Platform != PlatformID.Unix) {
111 |
112 | var dllPath = dllName;
113 | string dllDir = string.Empty;
114 |
115 | if (System.Environment.Is64BitProcess) {
116 | // "x64"
117 | dllDir = GetDllConfig (true);
118 | dllPath = System.IO.Path.Combine (dllDir, dllName);
119 | } else {
120 | // "x86"
121 | dllDir = GetDllConfig (false);
122 | dllPath = System.IO.Path.Combine (dllDir, dllName);
123 | }
124 |
125 | if (!File.Exists (dllPath)) {
126 | throw new FileNotFoundException (string.Format ("Unable to Load Dll. File not found: {0}", Path.GetFullPath (dllPath)), dllPath);
127 | }
128 |
129 | var path = Environment.GetEnvironmentVariable ("Path");
130 | var fullDllDir = Path.GetFullPath (dllDir);
131 | Environment.SetEnvironmentVariable ("Path", fullDllDir + ";" + path);
132 | path = Environment.GetEnvironmentVariable ("Path");
133 | //Console.WriteLine (path);
134 |
135 | //Console.WriteLine (dllPath);
136 | return true; //LoadLibraryInterop (dllPath) != IntPtr.Zero ? true : false;
137 | }
138 |
139 | return true;
140 | }
141 |
142 | // This is only available on Windows...but only required for Windows to work around 32-bit vs 64-bit DllImport issues
143 | [DllImport ("kernel32.dll", EntryPoint = "LoadLibrary")]
144 | private static extern IntPtr LoadLibraryInterop (string dllToLoad);
145 | }
146 | }
147 |
148 |
--------------------------------------------------------------------------------
/HamLibPortNative.cs:
--------------------------------------------------------------------------------
1 | //
2 | // HamLibPortNative.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 |
26 | namespace HamLibSharp
27 | {
28 | // TODO: The port struct is not really useful yet. It is used to as place
29 | // holder for Marshal copying
30 | // [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
31 | // internal struct HamLibCommPortNative
32 | // {
33 | // RigPort rig;
34 | //
35 | // int fd;
36 | // /*!< File descriptor */
37 | // IntPtr handle;
38 | // /*!< handle for USB */
39 | //
40 | // int write_delay;
41 | // /*!< Delay between each byte sent out, in mS */
42 | // int post_write_delay;
43 | // /*!< Delay between each commands send out, in mS */
44 | // int tv_sec;
45 | // int tv_usec;
46 | // //} post_write_date; /*!< hamlib internal use */
47 | // int timeout;
48 | // /*!< Timeout, in mS */
49 | // int retry;
50 | // /*!< Maximum number of retries, 0 to disable */
51 | //
52 | // [MarshalAs (UnmanagedType.ByValTStr, SizeConst = Rig.FILPATHLEN)]
53 | // string pathname;
54 | // /*!< Port pathname */
55 | //
56 | // int rate;
57 | // /*!< Serial baud rate */
58 | // int data_bits;
59 | // /*!< Number of data bits */
60 | // int stop_bits;
61 | // /*!< Number of stop bits */
62 | // RigSerialParity parity;
63 | // /*!< Serial parity */
64 | // RigSerialHandshake handshake;
65 | // /*!< Serial handshake */
66 | // RigSerialControlState rts_state;
67 | // /*!< RTS set state */
68 | // RigSerialControlState dtr_state;
69 | // /*!< DTR set state */
70 | //
71 | // int test;
72 | // /*!< alternate */
73 | // int test2;
74 | // /*!< alternate */
75 | // }
76 |
77 | [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
78 | internal struct HamLibPortNative
79 | {
80 | // union {
81 | // rig_port_t rig; /*!< Communication port type */
82 | // ptt_type_t ptt; /*!< PTT port type */
83 | // dcd_type_t dcd; /*!< DCD port type */
84 | // } type;
85 | IntPtr rig_ptt_dcd;
86 |
87 | IntPtr fd;
88 | /*!< File descriptor */
89 | IntPtr handle;
90 | /*!< handle for USB */
91 |
92 | int write_delay;
93 | /*!< Delay between each byte sent out, in mS */
94 | int post_write_delay;
95 | /*!< Delay between each commands send out, in mS */
96 | int tv_sec;
97 | int tv_usec;
98 | //} post_write_date; /*!< hamlib internal use */
99 | int timeout;
100 | /*!< Timeout, in mS */
101 | int retry;
102 | /*!< Maximum number of retries, 0 to disable */
103 |
104 | [MarshalAs (UnmanagedType.ByValTStr, SizeConst = Rig.FILPATHLEN)]
105 | string pathname;
106 | /*!< Port pathname */
107 |
108 | int vid;
109 | /*!< Vendor ID */
110 | int pid;
111 | /*!< Product ID */
112 | int conf;
113 | /*!< Configuration */
114 | int iface;
115 | /*!< interface */
116 | int alt;
117 | /*!< alternate */
118 | IntPtr vendor_name;
119 | /*!< Vendor name (opt.) */
120 | IntPtr product;
121 | /*!< Product (opt.) */
122 |
123 | //int test;
124 | /*!< alternate */
125 | //int test2;
126 | /*!< alternate */
127 |
128 | // union {
129 | // struct {
130 | // int rate; /*!< Serial baud rate */
131 | // int data_bits; /*!< Number of data bits */
132 | // int stop_bits; /*!< Number of stop bits */
133 | // enum serial_parity_e parity; /*!< Serial parity */
134 | // enum serial_handshake_e handshake; /*!< Serial handshake */
135 | // enum serial_control_state_e rts_state; /*!< RTS set state */
136 | // enum serial_control_state_e dtr_state; /*!< DTR set state */
137 | // } serial; /*!< serial attributes */
138 | // struct {
139 | // int pin; /*!< Parallel port pin number */
140 | // } parallel; /*!< parallel attributes */
141 | // struct {
142 | // int ptt_bitnum; /*< Bit number for CM108 GPIO PTT */
143 | // } cm108; /*!< CM108 attributes */
144 | // struct {
145 | // int vid; /*!< Vendor ID */
146 | // int pid; /*!< Product ID */
147 | // int conf; /*!< Configuration */
148 | // int iface; /*!< interface */
149 | // int alt; /*!< alternate */
150 | // char *vendor_name; /*!< Vendor name (opt.) */
151 | // char *product; /*!< Product (opt.) */
152 | // } usb; /*!< USB attributes */
153 | // struct {
154 | // int on_value;
155 | // int value;
156 | // } gpio;
157 | // } parm; /*!< Port parameter union */
158 | // } hamlib_port_t;
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/HamLibSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {878402CD-1AF7-443F-980F-861FF9E840CD}
7 | Library
8 | HamLibSharp
9 | HamLibSharp
10 | v4.5.1
11 |
12 |
13 | true
14 | full
15 | false
16 | build\Debug
17 | DEBUG;
18 | prompt
19 | 4
20 | false
21 |
22 |
23 | full
24 | true
25 | build\Release
26 | prompt
27 | 4
28 | false
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | bld/
19 | build/
20 | [Bb]in/
21 | [Oo]bj/
22 | [Ll]og/
23 |
24 | # Visual Studio 2015 cache/options directory
25 | .vs/
26 | # Uncomment if you have tasks that create the project's static files in wwwroot
27 | #wwwroot/
28 |
29 | # MSTest test Results
30 | [Tt]est[Rr]esult*/
31 | [Bb]uild[Ll]og.*
32 |
33 | # NUNIT
34 | *.VisualState.xml
35 | TestResult.xml
36 |
37 | # Build Results of an ATL Project
38 | [Dd]ebugPS/
39 | [Rr]eleasePS/
40 | dlldata.c
41 |
42 | # DNX
43 | project.lock.json
44 | project.fragment.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 | *.VC.VC.opendb
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
149 | # checkin your Azure Web App publish settings, but sensitive information contained
150 | # in these scripts will be unencrypted
151 | PublishScripts/
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 | # NuGet v3's project.json files produces more ignoreable files
162 | *.nuget.props
163 | *.nuget.targets
164 |
165 | # Microsoft Azure Build Output
166 | csx/
167 | *.build.csdef
168 |
169 | # Microsoft Azure Emulator
170 | ecf/
171 | rcf/
172 |
173 | # Windows Store app package directories and files
174 | AppPackages/
175 | BundleArtifacts/
176 | Package.StoreAssociation.xml
177 | _pkginfo.txt
178 |
179 | # Visual Studio cache files
180 | # files ending in .cache can be ignored
181 | *.[Cc]ache
182 | # but keep track of directories ending in .cache
183 | !*.[Cc]ache/
184 |
185 | # Others
186 | ClientBin/
187 | ~$*
188 | *~
189 | *.dbmdl
190 | *.dbproj.schemaview
191 | *.pfx
192 | *.publishsettings
193 | node_modules/
194 | orleans.codegen.cs
195 |
196 | # Since there are multiple workflows, uncomment next line to ignore bower_components
197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198 | #bower_components/
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # Paket dependency manager
244 | .paket/paket.exe
245 | paket-files/
246 |
247 | # FAKE - F# Make
248 | .fake/
249 |
250 | # JetBrains Rider
251 | .idea/
252 | *.sln.iml
253 |
254 | # CodeRush
255 | .cr/
256 |
257 |
--------------------------------------------------------------------------------
/IRigCapsNative.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigCapsNative.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 |
26 | namespace HamLibSharp
27 | {
28 | ///
29 | /// Rig caps native interface.
30 | /// There is an ABI issue with HamLib where shortfreq_t and pbwidth_t are defined as "long"
31 | /// and setting_t is defined as "unsigned long".
32 | /// On Linux and Posix:
33 | /// long is defined as 32-bits on 32-bit systems
34 | /// long is defined as 64-bits on 64-bit systems
35 | /// On Windows:
36 | /// long is always defined as 32-bits for both 32 and 64-bit systems.
37 | ///
38 | /// This interface is used to abstract the native struct from the implementation so
39 | /// each architecture specific struct can be used to Marshal the data using PtrToStructure
40 | /// and all variables line up with native memory.
41 | ///
42 | internal interface IRigCapsNative
43 | {
44 | int Rig_model { get; }
45 |
46 | string Model_name { get; }
47 |
48 | string Mfg_name { get; }
49 |
50 | string Version { get; }
51 |
52 | string Copyright { get; }
53 |
54 | RigBackendStatus Status { get; }
55 |
56 | RigType Rig_type { get; }
57 |
58 | PttType Ptt_type { get; }
59 |
60 | RigDcd Dcd_type { get; }
61 |
62 | RigPort Port_type { get; }
63 |
64 | int Serial_rate_min { get; }
65 |
66 | int Serial_rate_max { get; }
67 |
68 | int Serial_data_bits { get; }
69 |
70 | int Serial_stop_bits { get; }
71 |
72 | RigSerialParity Serial_parity { get; }
73 |
74 | RigSerialHandshake Serial_handshake { get; }
75 |
76 | int Write_delay { get; }
77 |
78 | int Post_write_delay { get; }
79 |
80 | int Timeout { get; }
81 |
82 | int Retry { get; }
83 |
84 | uint Has_get_func { get; }
85 |
86 | uint Has_set_func { get; }
87 |
88 | uint Has_get_level { get; }
89 |
90 | uint Has_set_level { get; }
91 |
92 | uint Has_get_parm { get; }
93 |
94 | uint Has_set_parm { get; }
95 |
96 | Granularity[] Level_gran { get; }
97 |
98 | Granularity[] Parm_gran { get; }
99 |
100 | IntPtr Extparms { get; }
101 |
102 | IntPtr Extlevels { get; }
103 |
104 | IntPtr Ctcss_list { get; }
105 |
106 | IntPtr Dcs_list { get; }
107 |
108 | int[] Preamp { get; }
109 |
110 | int[] Attenuator { get; }
111 |
112 | int Max_rit { get; }
113 |
114 | int Max_xit { get; }
115 |
116 | int Max_ifshift { get; }
117 |
118 | RigAnnounce Announces { get; }
119 |
120 | RigVfoOperation Vfo_ops { get; }
121 |
122 | RigScanOperation Scan_ops { get; }
123 |
124 | int Targetable_vfo { get; }
125 |
126 | RigTransceive Transceive { get; }
127 |
128 | int Bank_qty { get; }
129 |
130 | int Chan_desc_sz { get; }
131 |
132 | IList Chan_list { get; }
133 |
134 | FrequencyRange[] Rx_range_list1 { get; }
135 |
136 | FrequencyRange[] Tx_range_list1 { get; }
137 |
138 | FrequencyRange[] Rx_range_list2 { get; }
139 |
140 | FrequencyRange[] Tx_range_list2 { get; }
141 |
142 | IList Tuning_steps { get; }
143 |
144 | IList Filters_list { get; }
145 |
146 | CalibrationTable Str_cal { get; }
147 |
148 | IntPtr Cfgparams { get; }
149 |
150 | IntPtr Priv { get; }
151 |
152 | IntPtr Rig_init { get; }
153 |
154 | IntPtr Rig_cleanup { get; }
155 |
156 | IntPtr Rig_open { get; }
157 |
158 | IntPtr Rig_close { get; }
159 |
160 | IntPtr Set_freq { get; }
161 |
162 | IntPtr Get_freq { get; }
163 |
164 | IntPtr Set_mode { get; }
165 |
166 | IntPtr Get_mode { get; }
167 |
168 | IntPtr Set_vfo { get; }
169 |
170 | IntPtr Get_vfo { get; }
171 |
172 | IntPtr Set_ptt { get; }
173 |
174 | IntPtr Get_ptt { get; }
175 |
176 | IntPtr Get_dcd { get; }
177 |
178 | IntPtr Set_rptr_shift { get; }
179 |
180 | IntPtr Get_rptr_shift { get; }
181 |
182 | IntPtr Set_rptr_offs { get; }
183 |
184 | IntPtr Get_rptr_offs { get; }
185 |
186 | IntPtr Set_split_freq { get; }
187 |
188 | IntPtr Get_split_freq { get; }
189 |
190 | IntPtr Set_split_mode { get; }
191 |
192 | IntPtr Get_split_mode { get; }
193 |
194 | IntPtr Set_split_freq_mode { get; }
195 |
196 | IntPtr Get_split_freq_mode { get; }
197 |
198 | IntPtr Set_split_vfo { get; }
199 |
200 | IntPtr Get_split_vfo { get; }
201 |
202 | IntPtr Set_rit { get; }
203 |
204 | IntPtr Get_rit { get; }
205 |
206 | IntPtr Set_xit { get; }
207 |
208 | IntPtr Get_xit { get; }
209 |
210 | IntPtr Set_ts { get; }
211 |
212 | IntPtr Get_ts { get; }
213 |
214 | IntPtr Set_dcs_code { get; }
215 |
216 | IntPtr Get_dcs_code { get; }
217 |
218 | IntPtr Set_tone { get; }
219 |
220 | IntPtr Get_tone { get; }
221 |
222 | IntPtr Set_ctcss_tone { get; }
223 |
224 | IntPtr Get_ctcss_tone { get; }
225 |
226 | IntPtr Set_dcs_sql { get; }
227 |
228 | IntPtr Get_dcs_sql { get; }
229 |
230 | IntPtr Set_tone_sql { get; }
231 |
232 | IntPtr Get_tone_sql { get; }
233 |
234 | IntPtr Set_ctcss_sql { get; }
235 |
236 | IntPtr Get_ctcss_sql { get; }
237 |
238 | IntPtr Power2mW { get; }
239 |
240 | IntPtr MW2power { get; }
241 |
242 | IntPtr Set_powerstat { get; }
243 |
244 | IntPtr Get_powerstat { get; }
245 |
246 | IntPtr Reset { get; }
247 |
248 | IntPtr Set_ant { get; }
249 |
250 | IntPtr Get_ant { get; }
251 |
252 | IntPtr Set_level { get; }
253 |
254 | IntPtr Get_level { get; }
255 |
256 | IntPtr Set_func { get; }
257 |
258 | IntPtr Get_func { get; }
259 |
260 | IntPtr Set_parm { get; }
261 |
262 | IntPtr Get_parm { get; }
263 |
264 | IntPtr Set_ext_level { get; }
265 |
266 | IntPtr Get_ext_level { get; }
267 |
268 | IntPtr Set_ext_parm { get; }
269 |
270 | IntPtr Get_ext_parm { get; }
271 |
272 | IntPtr Set_conf { get; }
273 |
274 | IntPtr Get_conf { get; }
275 |
276 | IntPtr Send_dtmf { get; }
277 |
278 | IntPtr Recv_dtmf { get; }
279 |
280 | IntPtr Send_morse { get; }
281 |
282 | IntPtr Set_bank { get; }
283 |
284 | IntPtr Set_mem { get; }
285 |
286 | IntPtr Get_mem { get; }
287 |
288 | IntPtr Vfo_op { get; }
289 |
290 | IntPtr Scan { get; }
291 |
292 | IntPtr Set_trn { get; }
293 |
294 | IntPtr Get_trn { get; }
295 |
296 | IntPtr Decode_event { get; }
297 |
298 | IntPtr Set_channel { get; }
299 |
300 | IntPtr Get_channel { get; }
301 |
302 | IntPtr Get_info { get; }
303 |
304 | IntPtr Set_chan_all_cb { get; }
305 |
306 | IntPtr Get_chan_all_cb { get; }
307 |
308 | IntPtr Set_mem_all_cb { get; }
309 |
310 | IntPtr Get_mem_all_cb { get; }
311 |
312 | IntPtr Clone_combo_set { get; }
313 |
314 | IntPtr Clone_combo_get { get; }
315 | }
316 | }
317 |
--------------------------------------------------------------------------------
/x86/RigStateNative32.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigStateNative32.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 |
27 | namespace HamLibSharp.x86
28 | {
29 | // TODO: Primary interest is to get the vfo_list and mode_list. Everything else untested.
30 | [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
31 | internal struct RigStateNative32 : IRigStateNative
32 | {
33 | // max mode/filter list size, zero ended
34 | // NOTE: This was changed from 42 to 60 in version 3.0.1
35 | internal const int FLTLSTSIZ = 60;
36 |
37 | // [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 1)]
38 | // HamLibCommPortNative port; /// Rig port (internal use).
39 |
40 | /// Rig port (internal use).
41 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 3)]
42 | internal HamLibPortNative[] ptt_dcd_ports;
43 |
44 | /// VFO compensation in PPM, 0.0 to disable
45 | internal double vfo_comp;
46 |
47 | /// ITU region to select among freq_range_t
48 | internal int itu_region;
49 |
50 | /// Receive frequency range list
51 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
52 | internal FrequencyRange[] rx_range_list;
53 |
54 | /// Transmit frequency range list
55 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
56 | internal FrequencyRange[] tx_range_list;
57 |
58 | // Tuning step list
59 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.TSLSTSIZ)]
60 | internal ModeValue32[] tuning_steps;
61 |
62 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = FLTLSTSIZ)]
63 | internal ModeValue32[] filters;
64 |
65 | // S-meter calibration table
66 | internal CalibrationTable str_cal;
67 |
68 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.CHANLSTSIZ)]
69 | internal ChannelList32[] chan_list;
70 |
71 | /// max absolute
72 | internal int max_rit;
73 | /// max absolute XIT
74 | internal int max_xit;
75 | /// max absolute IF-SHIFT
76 | internal int max_ifshift;
77 |
78 | /// Announces bit field list
79 | internal RigAnnounce announces;
80 |
81 | // Preamp list in dB, 0 terminated
82 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
83 | internal int[] preamp;
84 |
85 | // Preamp list in dB, 0 terminated
86 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
87 | internal int[] attenuator;
88 |
89 | // List of get functions
90 | internal uint has_get_func;
91 | // List of set functions
92 | internal uint has_set_func;
93 | // List of get level
94 | internal uint has_get_level;
95 | // List of set level
96 | internal uint has_set_level;
97 | // List of get parm
98 | internal uint has_get_parm;
99 | // List of set parm
100 | internal uint has_set_parm;
101 |
102 | // level granularity (i.e. steps)
103 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
104 | internal Granularity[] level_gran;
105 |
106 | // parm granularity (i.e. steps)
107 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
108 | internal Granularity[] parm_gran;
109 |
110 | // non overridable fields, internal use
111 |
112 | /// set to 1 to hold the event decoder (async) otherwise 0
113 | internal int hold_decode;
114 | /// VFO currently set
115 | internal int current_vfo;
116 | /// Complete list of VFO for this rig
117 | internal int vfo_list;
118 | /// Comm port state, opened/closed.
119 | internal int comm_state;
120 | /// Pointer to private rig state data.
121 | IntPtr priv;
122 | /// Internal use by hamlib++ for event handling.
123 | IntPtr obj;
124 | /// Whether the transceive mode is on
125 | internal int transceive;
126 | /// Event notification polling period in milliseconds
127 | internal int poll_interval;
128 | /// Frequency currently set
129 | internal double current_freq;
130 | /// Mode currently set
131 | RigMode current_mode;
132 | /// Passband width currently set
133 | internal int current_width;
134 | /// Tx VFO currently set
135 | internal int tx_vfo;
136 | /// Complete list of modes for this rig
137 | internal RigMode mode_list;
138 |
139 | // interface properties
140 |
141 | public HamLibPortNative[] Ptt_dcd_ports { get { return ptt_dcd_ports; } }
142 | public double Vfo_comp { get { return vfo_comp; } }
143 | public int Itu_region { get { return itu_region; } }
144 | public FrequencyRange[] Rx_range_list { get { return rx_range_list; } }
145 | public FrequencyRange[] Tx_range_list { get { return tx_range_list; } }
146 | public IList Tuning_steps { get { return tuning_steps.CastList(); } }
147 | public IList Filters { get { return filters.CastList(); } }
148 | public CalibrationTable Str_cal { get { return str_cal; } }
149 | public IList Chan_list { get { return chan_list.CastList(); } }
150 | public int Max_rit { get { return max_rit; } }
151 | public int Max_xit { get { return max_xit; } }
152 | public int Max_ifshift { get { return max_ifshift; } }
153 | public RigAnnounce Announces { get { return announces; } }
154 | public int[] Preamp { get { return preamp; } }
155 | public int[] Attenuator { get { return attenuator; } }
156 | public uint Has_get_func { get { return has_get_func; } }
157 | public uint Has_set_func { get { return Has_set_func; } }
158 | public uint Has_get_level { get { return has_get_level; } }
159 | public uint Has_set_level { get { return has_set_level; } }
160 | public uint Has_get_parm { get { return has_get_parm; } }
161 | public uint Has_set_parm { get { return has_set_parm; } }
162 | public Granularity[] Level_gran { get { return level_gran; } }
163 | public Granularity[] Parm_gran { get { return parm_gran; } }
164 | public int Hold_decode { get { return hold_decode; } }
165 | public int Current_vfo { get { return current_vfo; } }
166 | public int Vfo_list { get { return vfo_list; } }
167 | public int Comm_state { get { return comm_state; } }
168 | public IntPtr Priv { get { return priv; } }
169 | public IntPtr Obj { get { return obj; } }
170 | public int Transceive { get { return transceive; } }
171 | public int Poll_interval { get { return poll_interval; } }
172 | public double Current_freq { get { return current_freq; } }
173 | public RigMode Current_mode { get { return current_mode; } }
174 | public int Current_width { get { return current_width; } }
175 | public int Tx_vfo { get { return tx_vfo; } }
176 | public RigMode Mode_list { get { return mode_list; } }
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/x86/RigStateNative32v2.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigStateNative32v2.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 |
27 | namespace HamLibSharp.x86
28 | {
29 | // TODO: Primary interest is to get the vfo_list and mode_list. Everything else untested.
30 | [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
31 | internal struct RigStateNative32v2 : IRigStateNative
32 | {
33 | // max mode/filter list size, zero ended
34 | // NOTE: This was changed from 42 to 60 in version 3.0.1
35 | internal const int FLTLSTSIZ = 42;
36 |
37 | // [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 1)]
38 | // HamLibCommPortNative port; /// Rig port (internal use).
39 |
40 | /// Rig port (internal use).
41 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 3)]
42 | internal HamLibPortNative[] ptt_dcd_ports;
43 |
44 | /// VFO compensation in PPM, 0.0 to disable
45 | internal double vfo_comp;
46 |
47 | /// ITU region to select among freq_range_t
48 | internal int itu_region;
49 |
50 | /// Receive frequency range list
51 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
52 | internal FrequencyRange[] rx_range_list;
53 |
54 | /// Transmit frequency range list
55 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
56 | internal FrequencyRange[] tx_range_list;
57 |
58 | // Tuning step list
59 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.TSLSTSIZ)]
60 | internal ModeValue32[] tuning_steps;
61 |
62 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = FLTLSTSIZ)]
63 | internal ModeValue32[] filters;
64 |
65 | // S-meter calibration table
66 | internal CalibrationTable str_cal;
67 |
68 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.CHANLSTSIZ)]
69 | internal ChannelList32[] chan_list;
70 |
71 | /// max absolute
72 | internal int max_rit;
73 | /// max absolute XIT
74 | internal int max_xit;
75 | /// max absolute IF-SHIFT
76 | internal int max_ifshift;
77 |
78 | /// Announces bit field list
79 | internal RigAnnounce announces;
80 |
81 | // Preamp list in dB, 0 terminated
82 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
83 | internal int[] preamp;
84 |
85 | // Preamp list in dB, 0 terminated
86 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
87 | internal int[] attenuator;
88 |
89 | // List of get functions
90 | internal uint has_get_func;
91 | // List of set functions
92 | internal uint has_set_func;
93 | // List of get level
94 | internal uint has_get_level;
95 | // List of set level
96 | internal uint has_set_level;
97 | // List of get parm
98 | internal uint has_get_parm;
99 | // List of set parm
100 | internal uint has_set_parm;
101 |
102 | // level granularity (i.e. steps)
103 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
104 | internal Granularity[] level_gran;
105 |
106 | // parm granularity (i.e. steps)
107 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
108 | internal Granularity[] parm_gran;
109 |
110 | // non overridable fields, internal use
111 |
112 | /// set to 1 to hold the event decoder (async) otherwise 0
113 | internal int hold_decode;
114 | /// VFO currently set
115 | internal int current_vfo;
116 | /// Complete list of VFO for this rig
117 | internal int vfo_list;
118 | /// Comm port state, opened/closed.
119 | internal int comm_state;
120 | /// Pointer to private rig state data.
121 | IntPtr priv;
122 | /// Internal use by hamlib++ for event handling.
123 | IntPtr obj;
124 | /// Whether the transceive mode is on
125 | internal int transceive;
126 | /// Event notification polling period in milliseconds
127 | internal int poll_interval;
128 | /// Frequency currently set
129 | internal double current_freq;
130 | /// Mode currently set
131 | RigMode current_mode;
132 | /// Passband width currently set
133 | internal int current_width;
134 | /// Tx VFO currently set
135 | internal int tx_vfo;
136 | /// Complete list of modes for this rig
137 | internal RigMode mode_list;
138 |
139 | // interface properties
140 |
141 | public HamLibPortNative[] Ptt_dcd_ports { get { return ptt_dcd_ports; } }
142 | public double Vfo_comp { get { return vfo_comp; } }
143 | public int Itu_region { get { return itu_region; } }
144 | public FrequencyRange[] Rx_range_list { get { return rx_range_list; } }
145 | public FrequencyRange[] Tx_range_list { get { return tx_range_list; } }
146 | public IList Tuning_steps { get { return tuning_steps.CastList(); } }
147 | public IList Filters { get { return filters.CastList(); } }
148 | public CalibrationTable Str_cal { get { return str_cal; } }
149 | public IList Chan_list { get { return chan_list.CastList(); } }
150 | public int Max_rit { get { return max_rit; } }
151 | public int Max_xit { get { return max_xit; } }
152 | public int Max_ifshift { get { return max_ifshift; } }
153 | public RigAnnounce Announces { get { return announces; } }
154 | public int[] Preamp { get { return preamp; } }
155 | public int[] Attenuator { get { return attenuator; } }
156 | public uint Has_get_func { get { return has_get_func; } }
157 | public uint Has_set_func { get { return Has_set_func; } }
158 | public uint Has_get_level { get { return has_get_level; } }
159 | public uint Has_set_level { get { return has_set_level; } }
160 | public uint Has_get_parm { get { return has_get_parm; } }
161 | public uint Has_set_parm { get { return has_set_parm; } }
162 | public Granularity[] Level_gran { get { return level_gran; } }
163 | public Granularity[] Parm_gran { get { return parm_gran; } }
164 | public int Hold_decode { get { return hold_decode; } }
165 | public int Current_vfo { get { return current_vfo; } }
166 | public int Vfo_list { get { return vfo_list; } }
167 | public int Comm_state { get { return comm_state; } }
168 | public IntPtr Priv { get { return priv; } }
169 | public IntPtr Obj { get { return obj; } }
170 | public int Transceive { get { return transceive; } }
171 | public int Poll_interval { get { return poll_interval; } }
172 | public double Current_freq { get { return current_freq; } }
173 | public RigMode Current_mode { get { return current_mode; } }
174 | public int Current_width { get { return current_width; } }
175 | public int Tx_vfo { get { return tx_vfo; } }
176 | public RigMode Mode_list { get { return mode_list; } }
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/x64/RigStateNative64v2.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigStateNative64v2.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 |
27 | namespace HamLibSharp.x64
28 | {
29 | // TODO: Primary interest is to get the vfo_list and mode_list. Everything else untested.
30 | [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
31 | internal struct RigStateNative64v2 : IRigStateNative
32 | {
33 | // max mode/filter list size, zero ended
34 | // NOTE: This was changed from 42 to 60 in version 3.0.1
35 | internal const int FLTLSTSIZ = 42;
36 |
37 | // [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 1)]
38 | // HamLibCommPortNative port; /// Rig port (internal use).
39 |
40 | /// Rig port (internal use).
41 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 3)]
42 | internal HamLibPortNative[] ptt_dcd_ports;
43 |
44 | /// VFO compensation in PPM, 0.0 to disable
45 | internal double vfo_comp;
46 |
47 | /// ITU region to select among freq_range_t
48 | internal int itu_region;
49 |
50 | /// Receive frequency range list
51 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
52 | internal FrequencyRange[] rx_range_list;
53 |
54 | /// Transmit frequency range list
55 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
56 | internal FrequencyRange[] tx_range_list;
57 |
58 | // Tuning step list
59 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.TSLSTSIZ)]
60 | internal ModeValue64[] tuning_steps;
61 |
62 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = FLTLSTSIZ)]
63 | internal ModeValue64[] filters;
64 |
65 | // S-meter calibration table
66 | internal CalibrationTable str_cal;
67 |
68 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.CHANLSTSIZ)]
69 | internal ChannelList64[] chan_list;
70 |
71 | /// max absolute
72 | internal long max_rit;
73 | /// max absolute XIT
74 | internal long max_xit;
75 | /// max absolute IF-SHIFT
76 | internal long max_ifshift;
77 |
78 | /// Announces bit field list
79 | internal RigAnnounce announces;
80 |
81 | // Preamp list in dB, 0 terminated
82 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
83 | internal int[] preamp;
84 |
85 | // Preamp list in dB, 0 terminated
86 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
87 | internal int[] attenuator;
88 |
89 | // List of get functions
90 | internal ulong has_get_func;
91 | // List of set functions
92 | internal ulong has_set_func;
93 | // List of get level
94 | internal ulong has_get_level;
95 | // List of set level
96 | internal ulong has_set_level;
97 | // List of get parm
98 | internal ulong has_get_parm;
99 | // List of set parm
100 | internal ulong has_set_parm;
101 |
102 | // level granularity (i.e. steps)
103 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
104 | internal Granularity[] level_gran;
105 |
106 | // parm granularity (i.e. steps)
107 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
108 | internal Granularity[] parm_gran;
109 |
110 | // non overridable fields, internal use
111 |
112 | /// set to 1 to hold the event decoder (async) otherwise 0
113 | internal int hold_decode;
114 | /// VFO currently set
115 | internal int current_vfo;
116 | /// Complete list of VFO for this rig
117 | internal int vfo_list;
118 | /// Comm port state, opened/closed.
119 | internal int comm_state;
120 | /// Pointer to private rig state data.
121 | IntPtr priv;
122 | /// Internal use by hamlib++ for event handling.
123 | IntPtr obj;
124 | /// Whether the transceive mode is on
125 | internal int transceive;
126 | /// Event notification polling period in milliseconds
127 | internal int poll_interval;
128 | /// Frequency currently set
129 | internal double current_freq;
130 | /// Mode currently set
131 | RigMode current_mode;
132 | /// Passband width currently set
133 | internal long current_width;
134 | /// Tx VFO currently set
135 | internal int tx_vfo;
136 | /// Complete list of modes for this rig
137 | internal RigMode mode_list;
138 |
139 | // interface properties
140 |
141 | public HamLibPortNative[] Ptt_dcd_ports { get { return ptt_dcd_ports; } }
142 | public double Vfo_comp { get { return vfo_comp; } }
143 | public int Itu_region { get { return itu_region; } }
144 | public FrequencyRange[] Rx_range_list { get { return rx_range_list; } }
145 | public FrequencyRange[] Tx_range_list { get { return tx_range_list; } }
146 | public IList Tuning_steps { get { return tuning_steps.CastList(); } }
147 | public IList Filters { get { return filters.CastList(); } }
148 | public CalibrationTable Str_cal { get { return str_cal; } }
149 | public IList Chan_list { get { return chan_list.CastList(); } }
150 | public int Max_rit { get { return (int)max_rit; } }
151 | public int Max_xit { get { return (int)max_xit; } }
152 | public int Max_ifshift { get { return (int)max_ifshift; } }
153 | public RigAnnounce Announces { get { return announces; } }
154 | public int[] Preamp { get { return preamp; } }
155 | public int[] Attenuator { get { return attenuator; } }
156 | public uint Has_get_func { get { return (uint)has_get_func; } }
157 | public uint Has_set_func { get { return (uint)has_set_func; } }
158 | public uint Has_get_level { get { return (uint)has_get_level; } }
159 | public uint Has_set_level { get { return (uint)has_set_level; } }
160 | public uint Has_get_parm { get { return (uint)has_get_parm; } }
161 | public uint Has_set_parm { get { return (uint)has_set_parm; } }
162 | public Granularity[] Level_gran { get { return level_gran; } }
163 | public Granularity[] Parm_gran { get { return parm_gran; } }
164 | public int Hold_decode { get { return hold_decode; } }
165 | public int Current_vfo { get { return current_vfo; } }
166 | public int Vfo_list { get { return vfo_list; } }
167 | public int Comm_state { get { return comm_state; } }
168 | public IntPtr Priv { get { return priv; } }
169 | public IntPtr Obj { get { return obj; } }
170 | public int Transceive { get { return transceive; } }
171 | public int Poll_interval { get { return poll_interval; } }
172 | public double Current_freq { get { return current_freq; } }
173 | public RigMode Current_mode { get { return current_mode; } }
174 | public int Current_width { get { return (int)current_width; } }
175 | public int Tx_vfo { get { return tx_vfo; } }
176 | public RigMode Mode_list { get { return mode_list; } }
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/x64/RigStateNative64.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigStateNative64.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 |
27 | namespace HamLibSharp.x64
28 | {
29 |
30 | // TODO: Primary interest is to get the vfo_list and mode_list. Everything else untested.
31 | [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
32 | internal struct RigStateNative64 : IRigStateNative
33 | {
34 | // max mode/filter list size, zero ended
35 | // NOTE: This was changed from 42 to 60 in version 3.0.1
36 | internal const int FLTLSTSIZ = 60;
37 |
38 | // [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 1)]
39 | // HamLibCommPortNative port; /// Rig port (internal use).
40 |
41 | /// Rig port (internal use).
42 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 3)]
43 | internal HamLibPortNative[] ptt_dcd_ports;
44 |
45 | /// VFO compensation in PPM, 0.0 to disable
46 | internal double vfo_comp;
47 |
48 | /// ITU region to select among freq_range_t
49 | internal int itu_region;
50 |
51 | /// Receive frequency range list
52 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
53 | internal FrequencyRange[] rx_range_list;
54 |
55 | /// Transmit frequency range list
56 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
57 | internal FrequencyRange[] tx_range_list;
58 |
59 | // Tuning step list
60 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.TSLSTSIZ)]
61 | internal ModeValue64[] tuning_steps;
62 |
63 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = FLTLSTSIZ)]
64 | internal ModeValue64[] filters;
65 |
66 | // S-meter calibration table
67 | internal CalibrationTable str_cal;
68 |
69 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.CHANLSTSIZ)]
70 | internal ChannelList64[] chan_list;
71 |
72 | /// max absolute
73 | internal long max_rit;
74 | /// max absolute XIT
75 | internal long max_xit;
76 | /// max absolute IF-SHIFT
77 | internal long max_ifshift;
78 |
79 | /// Announces bit field list
80 | internal RigAnnounce announces;
81 |
82 | // Preamp list in dB, 0 terminated
83 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
84 | internal int[] preamp;
85 |
86 | // Preamp list in dB, 0 terminated
87 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
88 | internal int[] attenuator;
89 |
90 | // List of get functions
91 | internal ulong has_get_func;
92 | // List of set functions
93 | internal ulong has_set_func;
94 | // List of get level
95 | internal ulong has_get_level;
96 | // List of set level
97 | internal ulong has_set_level;
98 | // List of get parm
99 | internal ulong has_get_parm;
100 | // List of set parm
101 | internal ulong has_set_parm;
102 |
103 | // level granularity (i.e. steps)
104 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
105 | internal Granularity[] level_gran;
106 |
107 | // parm granularity (i.e. steps)
108 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
109 | internal Granularity[] parm_gran;
110 |
111 | // non overridable fields, internal use
112 |
113 | /// set to 1 to hold the event decoder (async) otherwise 0
114 | internal int hold_decode;
115 | /// VFO currently set
116 | internal int current_vfo;
117 | /// Complete list of VFO for this rig
118 | internal int vfo_list;
119 | /// Comm port state, opened/closed.
120 | internal int comm_state;
121 | /// Pointer to private rig state data.
122 | IntPtr priv;
123 | /// Internal use by hamlib++ for event handling.
124 | IntPtr obj;
125 | /// Whether the transceive mode is on
126 | internal int transceive;
127 | /// Event notification polling period in milliseconds
128 | internal int poll_interval;
129 | /// Frequency currently set
130 | internal double current_freq;
131 | /// Mode currently set
132 | RigMode current_mode;
133 | /// Passband width currently set
134 | internal long current_width;
135 | /// Tx VFO currently set
136 | internal int tx_vfo;
137 | /// Complete list of modes for this rig
138 | internal RigMode mode_list;
139 |
140 | // interface properties
141 |
142 | public HamLibPortNative[] Ptt_dcd_ports { get { return ptt_dcd_ports; } }
143 | public double Vfo_comp { get { return vfo_comp; } }
144 | public int Itu_region { get { return itu_region; } }
145 | public FrequencyRange[] Rx_range_list { get { return rx_range_list; } }
146 | public FrequencyRange[] Tx_range_list { get { return tx_range_list; } }
147 | public IList Tuning_steps { get { return tuning_steps.CastList(); } }
148 | public IList Filters { get { return filters.CastList(); } }
149 | public CalibrationTable Str_cal { get { return str_cal; } }
150 | public IList Chan_list { get { return chan_list.CastList(); } }
151 | public int Max_rit { get { return (int)max_rit; } }
152 | public int Max_xit { get { return (int)max_xit; } }
153 | public int Max_ifshift { get { return (int)max_ifshift; } }
154 | public RigAnnounce Announces { get { return announces; } }
155 | public int[] Preamp { get { return preamp; } }
156 | public int[] Attenuator { get { return attenuator; } }
157 | public uint Has_get_func { get { return (uint)has_get_func; } }
158 | public uint Has_set_func { get { return (uint)has_set_func; } }
159 | public uint Has_get_level { get { return (uint)has_get_level; } }
160 | public uint Has_set_level { get { return (uint)has_set_level; } }
161 | public uint Has_get_parm { get { return (uint)has_get_parm; } }
162 | public uint Has_set_parm { get { return (uint)has_set_parm; } }
163 | public Granularity[] Level_gran { get { return level_gran; } }
164 | public Granularity[] Parm_gran { get { return parm_gran; } }
165 | public int Hold_decode { get { return hold_decode; } }
166 | public int Current_vfo { get { return current_vfo; } }
167 | public int Vfo_list { get { return vfo_list; } }
168 | public int Comm_state { get { return comm_state; } }
169 | public IntPtr Priv { get { return priv; } }
170 | public IntPtr Obj { get { return obj; } }
171 | public int Transceive { get { return transceive; } }
172 | public int Poll_interval { get { return poll_interval; } }
173 | public double Current_freq { get { return current_freq; } }
174 | public RigMode Current_mode { get { return current_mode; } }
175 | public int Current_width { get { return (int)current_width; } }
176 | public int Tx_vfo { get { return tx_vfo; } }
177 | public RigMode Mode_list { get { return mode_list; } }
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/HamLib.cs:
--------------------------------------------------------------------------------
1 | //
2 | // HamLib.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 | using HamLibSharp.Utils;
27 | using HamLibSharp.x86;
28 | using HamLibSharp.x64;
29 |
30 | namespace HamLibSharp
31 | {
32 | internal enum HamLibVersion
33 | {
34 | Unknown = 0,
35 | V2 = 2,
36 | V301 = 3,
37 | Current,
38 | }
39 |
40 | public static class HamLib
41 | {
42 | internal readonly static bool bitsize64;
43 | internal readonly static bool isWindows;
44 | internal readonly static HamLibVersion hamLibVersion;
45 |
46 | public static bool Initialized { get; private set; }
47 |
48 | public readonly static SortedDictionary Rigs = new SortedDictionary ();
49 |
50 | [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
51 | public delegate int RigListCallback (IntPtr rig_caps, IntPtr rig_ptr);
52 |
53 | internal const string dllName = "libhamlib-2.dll";
54 |
55 | static HamLib ()
56 | {
57 | // determine platform and bit size...
58 | if (System.Environment.Is64BitProcess) {
59 | bitsize64 = true;
60 | }
61 |
62 | if (System.Environment.OSVersion.Platform != PlatformID.MacOSX && System.Environment.OSVersion.Platform != PlatformID.Unix) {
63 | isWindows = true;
64 | }
65 |
66 | // take care of 32/64 bit native windows dll
67 | Library.LoadLibrary (dllName);
68 |
69 | hamLibVersion = PreInitLibrary ();
70 | }
71 |
72 | static HamLibVersion PreInitLibrary ()
73 | {
74 | INativeRig initRig = null;
75 | IRigCapsNative initCaps = null;
76 | HamLibVersion version;
77 |
78 | SetDebugLevel (RigDebugLevel.None);
79 |
80 | // test what version of hamlib is on our system use the Dummy Rig
81 | var theRig = Rig.rig_init (1);
82 |
83 | if (!isWindows && bitsize64) {
84 | initRig = Marshal.PtrToStructure (theRig);
85 | initCaps = Marshal.PtrToStructure (initRig.Caps);
86 | if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero) {
87 | version = HamLibVersion.Current;
88 | } else {
89 | initCaps = Marshal.PtrToStructure (initRig.Caps);
90 | if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero) {
91 | version = HamLibVersion.V301;
92 | } else {
93 | initCaps = Marshal.PtrToStructure (initRig.Caps);
94 | if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero) {
95 | version = HamLibVersion.V2;
96 | } else {
97 | version = HamLibVersion.Unknown;
98 | }
99 | }
100 | }
101 | } else {
102 | initRig = Marshal.PtrToStructure (theRig);
103 |
104 | initCaps = Marshal.PtrToStructure (initRig.Caps);
105 | if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero) {
106 | version = HamLibVersion.Current;
107 | } else {
108 | initCaps = Marshal.PtrToStructure (initRig.Caps);
109 | if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero) {
110 | version = HamLibVersion.V301;
111 | } else {
112 | initCaps = Marshal.PtrToStructure (initRig.Caps);
113 | if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero) {
114 | version = HamLibVersion.V2;
115 | } else {
116 | version = HamLibVersion.Unknown;
117 | }
118 | }
119 | }
120 | }
121 |
122 | return version;
123 | }
124 |
125 | public static void Initialize ()
126 | {
127 | //SetDebugLevel (RigDebugLevel.None);
128 |
129 | rig_load_all_backends ();
130 |
131 | rig_list_foreach ((rig_caps, rig_ptr) => {
132 | if (rig_caps != IntPtr.Zero) {
133 | var caps = MarshalRigCaps (rig_caps);
134 | AddRig (new RigCaps (caps));
135 | }
136 | return 1;
137 | }, IntPtr.Zero);
138 |
139 | //SetDebugLevel (RigDebugLevel.Verbose);
140 |
141 | Initialized = true;
142 | }
143 |
144 | internal static IRigCapsNative MarshalRigCaps (IntPtr rig_caps)
145 | {
146 | IRigCapsNative caps = null;
147 |
148 | switch (hamLibVersion) {
149 | case HamLibVersion.Current:
150 | // if the platform is 64-bit, but not windows
151 | if (!isWindows && bitsize64) {
152 | caps = Marshal.PtrToStructure (rig_caps);
153 | } else {
154 | caps = Marshal.PtrToStructure (rig_caps);
155 | }
156 | break;
157 | case HamLibVersion.V301:
158 | if (!isWindows && bitsize64) {
159 | caps = Marshal.PtrToStructure (rig_caps);
160 | } else {
161 | caps = Marshal.PtrToStructure (rig_caps);
162 | }
163 | break;
164 | case HamLibVersion.V2:
165 | if (!isWindows && bitsize64) {
166 | caps = Marshal.PtrToStructure (rig_caps);
167 | } else {
168 | caps = Marshal.PtrToStructure (rig_caps);
169 | }
170 | break;
171 | default:
172 | throw new RigException ("Unknown or Incompatible HamLib library found");
173 | }
174 |
175 | return caps;
176 | }
177 |
178 | private static void AddRig (RigCaps caps)
179 | {
180 | int index = 2;
181 | string modelName = string.Format ("{0}", caps.ModelName);
182 |
183 | while (Rigs.ContainsKey (modelName)) {
184 | modelName = string.Format ("{0}_{1}", caps.ModelName, index);
185 | index++;
186 | }
187 |
188 | Rigs.Add (modelName, caps);
189 | }
190 |
191 | [DllImport (HamLib.dllName, EntryPoint = "rig_set_debug")]
192 | public static extern void SetDebugLevel (RigDebugLevel debugLevel);
193 |
194 | [DllImport (HamLib.dllName, EntryPoint = "rig_load_all_backends")]
195 | private static extern int rig_load_all_backends ();
196 |
197 | [DllImport (HamLib.dllName, EntryPoint = "rig_list_foreach")]
198 | private static extern int rig_list_foreach (RigListCallback call, IntPtr ptr);
199 |
200 | //Note: Function introduced in version 3.1, earlier versions do not have it
201 | [DllImport (HamLib.dllName)]
202 | private static extern IntPtr rig_copyright ();
203 |
204 | public static string NativeCopyright {
205 | get {
206 | try {
207 |
208 | return Marshal.PtrToStringAnsi (rig_copyright ());
209 | } catch (EntryPointNotFoundException) {
210 | return "Unknown";
211 | }
212 | }
213 | }
214 |
215 | //Note: Function introduced in version 3.1, earlier versions do not have it
216 | [DllImport (HamLib.dllName)]
217 | private static extern IntPtr rig_license ();
218 |
219 | public static string NativeLicense {
220 | get {
221 | try {
222 |
223 | return Marshal.PtrToStringAnsi (rig_license ());
224 | } catch (EntryPointNotFoundException) {
225 | return "Unknown";
226 | }
227 | }
228 | }
229 |
230 | //Note: Function introduced in version 3.1, earlier versions do not have it
231 | [DllImport (HamLib.dllName)]
232 | private static extern IntPtr rig_version ();
233 |
234 | public static string NativeVersion {
235 | get {
236 | try {
237 | switch (hamLibVersion) {
238 | case HamLibVersion.Current:
239 | var ver = Marshal.PtrToStringAnsi (rig_version ());
240 | return ver.Replace ("Hamlib", string.Empty).Trim ();
241 | case HamLibVersion.V301:
242 | return "3.0.1";
243 | case HamLibVersion.V2:
244 | return "1.2 or earlier";
245 | default:
246 | return "Unknown";
247 | }
248 | } catch (EntryPointNotFoundException) {
249 | //Console.WriteLine (e);
250 | // Entry point not found, so it has to be 3.0.1 or earlier
251 | return "3.0.1 or earlier";
252 | // } catch (DllNotFoundException e) {
253 | // return "Native HamLib Not Found: " + e.Message;
254 | }
255 | }
256 | }
257 |
258 | public static string ManagedCopyright {
259 | get {
260 | return Library.Copyright;
261 | }
262 | }
263 |
264 | public static string ManagedLicense {
265 | get {
266 | return Library.License;
267 | }
268 | }
269 |
270 | public static Version ManagedVersion {
271 | get {
272 | return Library.Version;
273 | }
274 | }
275 | }
276 | }
277 |
--------------------------------------------------------------------------------
/Enums.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Enums.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Runtime.InteropServices;
25 | using HamLibSharp.Utils;
26 |
27 | namespace HamLibSharp
28 | {
29 | public enum RigDebugLevel
30 | {
31 | /// no bug reporting
32 | None = 0,
33 | /// serious bug
34 | Debug,
35 | /// error case (e.g. protocol, memory allocation)
36 | Error,
37 | /// warning
38 | Warn,
39 | /// verbose
40 | Verbose,
41 | /// tracing
42 | Trace
43 | }
44 |
45 | public enum RigBackendStatus
46 | {
47 | /// Alpha quality, i.e. development
48 | Alpha = 0,
49 | /// Written from available specs, rig unavailable for test, feedback wanted!
50 | Untested,
51 | /// Beta quality
52 | Beta,
53 | /// Stable
54 | Stable,
55 | /// Was stable, but something broke it!
56 | Buggy,
57 | };
58 |
59 | public enum PttType
60 | {
61 | /// No PTT available
62 | None = 0,
63 | /// Legacy PTT
64 | Rig,
65 | /// PTT control through serial DTR signal
66 | SerialDtr,
67 | /// PTT control through serial RTS signal
68 | SerialRts,
69 | /// PTT control through parallel port
70 | Parallel,
71 | /// Legacy PTT, supports RIG_PTT_ON_MIC/RIG_PTT_ON_DATA
72 | RigMicData,
73 | /// PTT control through CM108 GPIO pin
74 | CM108
75 | }
76 |
77 | // Radio power state
78 | [Flags]
79 | public enum PowerState
80 | {
81 | /// Power off
82 | Off = 0,
83 | /// Power on
84 | On = (1 << 0),
85 | /// Standby
86 | Standby = (1 << 1)
87 | }
88 |
89 | //Reset operation
90 | [Flags]
91 | public enum RigReset
92 | {
93 | /// No reset
94 | None = 0,
95 | /// Software reset
96 | Soft = (1 << 0),
97 | /// VFO reset
98 | Vfo = (1 << 1),
99 | /// Memory clear
100 | MemoryClear = (1 << 2),
101 | /// Master reset
102 | Master = (1 << 3)
103 | }
104 |
105 | //DCD type
106 | public enum RigDcd
107 | {
108 | /// No DCD available
109 | None = 0,
110 | /// Rig has DCD status support, i.e. rig has get_dcd cap
111 | Rig,
112 | /// DCD status from serial DSR signal
113 | SerialDsr,
114 | /// DCD status from serial CTS signal
115 | SerialCts,
116 | /// DCD status from serial CD signal
117 | SerialCar,
118 | /// DCD status from parallel port pin
119 | Parallel,
120 | /// DCD status from CM108 vol dn pin
121 | CM108
122 | }
123 |
124 | public enum RigPort
125 | {
126 | /// No port
127 | None = 0,
128 | /// Serial
129 | Serial,
130 | /// Network socket type
131 | Network,
132 | /// Device driver, like the WiNRADiO
133 | Device,
134 | /// AX.25 network type, e.g. SV8CS protocol
135 | Packet,
136 | /// DTMF protocol bridge via another rig, eg. Kenwood Sky Cmd System
137 | DTMF,
138 | /// IrDA Ultra protocol!
139 | IrdaUltra,
140 | /// RPC wrapper
141 | RPC,
142 | /// Parallel port
143 | Parallel,
144 | /// USB port
145 | USB,
146 | /// UDP Network socket type
147 | UdpNetwork,
148 | /// CM108 GPIO
149 | CM108,
150 | /// GPIO
151 | Gpio,
152 | /// GPIO Inverted
153 | GpioInverted,
154 | }
155 |
156 | //Serial parity
157 | public enum RigSerialParity
158 | {
159 | /// No parity
160 | None = 0,
161 | /// Odd
162 | Odd,
163 | /// Even
164 | Even,
165 | /// Mark
166 | Mark,
167 | /// Space
168 | Space
169 | }
170 |
171 | //Serial handshake
172 | public enum RigSerialHandshake
173 | {
174 | /// No handshake
175 | None = 0,
176 | /// Software XON/XOFF
177 | [TextName("XONXOFF")]
178 | XonXoff,
179 | /// Hardware CTS/RTS
180 | Hardware
181 | }
182 |
183 |
184 | //Serial control state
185 | public enum RigSerialControlState
186 | {
187 | /// Unset or tri-state
188 | Unset = 0,
189 | /// ON
190 | On,
191 | /// OFF
192 | Off
193 | }
194 |
195 | public enum RigSerialBaudRate
196 | {
197 | BaudNone = 0,
198 | Baud2400 = 2400,
199 | Baud4800 = 4800,
200 | Baud9600 = 9600,
201 | Baud14400 = 14400,
202 | Baud19200 = 19200,
203 | Baud28800 = 28800,
204 | Baud38400 = 38400,
205 | Baud56000 = 56000,
206 | Baud57600 = 57600,
207 | Baud115200 = 115200,
208 | Baud128000 = 128000,
209 | Baud256000 = 256000,
210 | }
211 |
212 | //Announce
213 | //Designate optional speech synthesizer.
214 | [Flags]
215 | public enum RigAnnounce
216 | {
217 | /// None
218 | None = 0,
219 | /// disable announces
220 | Off = None,
221 | /// Announce frequency
222 | Frequency = (1 << 0),
223 | /// Announce receive mode
224 | RxMode = (1 << 1),
225 | /// CW
226 | CW = (1 << 2),
227 | /// English
228 | English = (1 << 3),
229 | /// Japan
230 | Japan = (1 << 4)
231 | }
232 |
233 | //VFO operation
234 | //
235 | // A VFO operation is an action on a VFO (or tunable memory).
236 | // The difference with a function is that an action has no on/off
237 | // status, it is performed at once.
238 | //
239 | // Note: the vfo argument for some vfo operation may be irrelevant,
240 | // and thus will be ignored.
241 | //
242 | // The VFO/MEM "mode" is set by rig_set_vfo.
243 | // STRING used in rigctl
244 | [Flags]
245 | public enum RigVfoOperation : uint
246 | {
247 | /// '' No VFO_OP
248 | None = 0,
249 | /// CPY -- VFO A = VFO B
250 | Copy = (1 << 0),
251 | /// XCHG -- Exchange VFO A/B
252 | Exchange = (1 << 1),
253 | /// FROM_VFO -- VFO->MEM
254 | VfoToMem = (1 << 2),
255 | /// TO_VFO -- MEM->VFO
256 | MemToVfo = (1 << 3),
257 | /// MCL -- Memory clear
258 | MemoryClear = (1 << 4),
259 | /// UP -- UP increment VFO freq by tuning step*/
260 | StepUp = (1 << 5),
261 | /// DOWN -- DOWN decrement VFO freq by tuning step*/
262 | StepDown = (1 << 6),
263 | /// BAND_UP -- Band UP
264 | BandUp = (1 << 7),
265 | /// BAND_DOWN -- Band DOWN
266 | BandDown = (1 << 8),
267 | /// LEFT -- LEFT
268 | Left = (1 << 9),
269 | /// RIGHT -- RIGHT
270 | Right = (1 << 10),
271 | /// TUNE -- Start tune
272 | Tune = (1 << 11),
273 | /// TOGGLE -- Toggle VFOA and VFOB
274 | Toggle = (1 << 12)
275 | }
276 |
277 | //Rig Scan operation
278 | //
279 | // Various scan operations supported by a rig.
280 | // STRING used in rigctl
281 | //
282 | [Flags]
283 | public enum RigScanOperation
284 | {
285 | /// '' No Scan
286 | None = 0,
287 | //// MEM -- Scan all memory channels
288 | Memory = (1 << 0),
289 | /// SLCT -- Scan all selected memory channels
290 | Selected = (1 << 1),
291 | /// PRIO -- Priority watch (mem or call channel)
292 | Priority = (1 << 2),
293 | /// PROG -- Programmed(edge) scan
294 | Programmed = (1 << 3),
295 | /// DELTA -- delta-f scan
296 | Delta = (1 << 4),
297 | /// VFO -- most basic scan
298 | Vfo = (1 << 5),
299 | /// PLT -- Scan using pipelined tuning
300 | PipelinedTuning = (1 << 6),
301 | /// STOP -- Stop scanning
302 | Stop = (1 << 7),
303 | }
304 |
305 |
306 | //Memory channel type definition
307 | //
308 | // Definition of memory types. Depending on the type, the content
309 | // of the memory channel has to be interpreted accordingly.
310 | // For instance, a RIG_MTYPE_EDGE channel_t will hold only a start
311 | // or stop frequency.
312 | //
313 | public enum RigMemoryChannel
314 | {
315 | /// None
316 | None = 0,
317 | /// Regular
318 | Memory,
319 | /// Scan edge
320 | Edge,
321 | /// Call channel
322 | Call,
323 | /// Memory pad
324 | MemoryPad,
325 | /// Satellite
326 | Satellite,
327 | /// VFO/Band channel
328 | VfoBand,
329 | /// Priority channel
330 | Priority
331 | }
332 |
333 | //Radio mode
334 | //
335 | // Various modes supported by a rig.
336 | // STRING used in rigctl
337 | [Flags]
338 | public enum RigMode
339 | {
340 | /// '' -- None
341 | None = 0,
342 | /// AM -- Amplitude Modulation
343 | AM = (1 << 0),
344 | /// CW -- CW "normal" sideband
345 | CW = (1 << 1),
346 | /// USB -- Upper Side Band
347 | USB = (1 << 2),
348 | /// LSB -- Lower Side Band
349 | LSB = (1 << 3),
350 | /// RTTY -- Radio Teletype
351 | RTTY = (1 << 4),
352 | /// FM -- "narrow" band FM
353 | FM = (1 << 5),
354 | /// WFM -- broadcast wide FM
355 | WFM = (1 << 6),
356 | /// CWR -- CW "reverse" sideband
357 | CWR = (1 << 7),
358 | /// RTTYR -- RTTY "reverse" sideband
359 | RTTYR = (1 << 8),
360 | /// AMS -- Amplitude Modulation Synchronous
361 | AMS = (1 << 9),
362 | /// PKTLSB -- Packet/Digital LSB mode (dedicated port)
363 | [TextName("Packet LSB")]
364 | PacketLSB = (1 << 10),
365 | /// PKTUSB -- Packet/Digital USB mode (dedicated port)
366 | [TextName("Packet USB")]
367 | PacketUSB = (1 << 11),
368 | /// PKTFM -- Packet/Digital FM mode (dedicated port)
369 | [TextName("Packet FM")]
370 | PacketFM = (1 << 12),
371 | /// ECSSUSB -- Exalted Carrier Single Sideband USB
372 | EcssUSB = (1 << 13),
373 | /// ECSSLSB -- Exalted Carrier Single Sideband LSB
374 | EcssLSB = (1 << 14),
375 | /// FAX -- Facsimile Mode
376 | FAX = (1 << 15),
377 | /// SAM -- Synchronous AM double sideband
378 | SAM = (1 << 16),
379 | /// SAL -- Synchronous AM lower sideband
380 | SAL = (1 << 17),
381 | /// SAH -- Synchronous AM upper (higher) sideband
382 | SAH = (1 << 18),
383 | /// DSB -- Double sideband suppressed carrier
384 | DSB = (1 << 19),
385 | /// MUST ALWAYS BE LAST, Max Count for dumpcaps.c
386 | //TestMax
387 | }
388 | //rmode_t;
389 |
390 | //Hamlib error codes
391 | // Error code definition that can be returned by the Hamlib functions.
392 | // Unless stated otherwise, Hamlib functions return the negative value
393 | // of rig_errcode_e definitions in case of error, or 0 when successful.
394 | public enum RigError
395 | {
396 | /// No error, operation completed successfully
397 | OK = 0,
398 | /// invalid parameter
399 | InvalidParameter,
400 | /// invalid configuration (serial,..)
401 | InvalidConfiguration,
402 | /// memory shortage
403 | MemoryShortage,
404 | /// function not implemented, but will be
405 | NotImplemented,
406 | /// communication timed out
407 | Timeout,
408 | /// IO error, including open failed
409 | IO,
410 | /// Internal Hamlib error, huh!
411 | Internal,
412 | /// Protocol error
413 | Protocol,
414 | /// Command rejected by the rig
415 | CommandRejected,
416 | /// Command performed, but arg truncated
417 | ArgTruncated,
418 | /// function not available
419 | FunctionNotAvailable,
420 | /// VFO not targetable
421 | VFONotTargetable,
422 | /// Error talking on the bus
423 | BusError,
424 | /// Collision on the bus
425 | BusBusy,
426 | /// NULL RIG handle or any invalid pointer parameter in get arg
427 | InvalidRigHandle,
428 | /// Invalid VFO
429 | InvalidVFO,
430 | /// Argument out of domain of func
431 | ArgumentDomain
432 |
433 | }
434 |
435 | //PTT status
436 | public enum PttMode
437 | {
438 | /// PTT desactivated
439 | Off = 0,
440 | /// PTT activated
441 | On,
442 | /// PTT Mic only, fallbacks on RIG_PTT_ON if unavailable
443 | OnMic,
444 | /// PTT Data (Mic-muted), fallbacks on RIG_PTT_ON if unavailable
445 | OnData
446 | }
447 |
448 |
449 |
450 | //DCD status
451 | public enum DcdState
452 | {
453 | /// Squelch closed
454 | Off = 0,
455 | /// Squelch open
456 | On
457 | }
458 |
459 | //Repeater shift type
460 | public enum RepeaterShift
461 | {
462 | /// No repeater shift
463 | None = 0,
464 | /// "-" shift
465 | Minus,
466 | /// "+" shift
467 | Plus
468 | }
469 |
470 | //Split mode
471 | public enum RigSplit
472 | {
473 | /// Split mode disabled
474 | Off = 0,
475 | /// Split mode enabled
476 | On
477 | }
478 |
479 | [Flags]
480 | public enum RigLevel
481 | {
482 | /// '' -- No Level
483 | None = 0,
484 | /// PREAMP -- Preamp, arg int (dB)
485 | Preamp = (1 << 0),
486 | /// ATT -- Attenuator, arg int (dB)
487 | Attenuator = (1 << 1),
488 | /// VOX -- VOX delay, arg int (tenth of seconds)
489 | Vox = (1 << 2),
490 | /// AF -- Volume, arg float [0.0 ... 1.0]
491 | Volume = (1 << 3),
492 | /// RF -- RF gain (not TX power), arg float [0.0 ... 1.0]
493 | RF = (1 << 4),
494 | /// SQL -- Squelch, arg float [0.0 ... 1.0]
495 | Squelch = (1 << 5),
496 | /// IF -- IF, arg int (Hz)
497 | IF = (1 << 6),
498 | /// APF -- Audio Peak Filter, arg float [0.0 ... 1.0]
499 | AudioPeakFilter = (1 << 7),
500 | /// NR -- Noise Reduction, arg float [0.0 ... 1.0]
501 | NoiseReduction = (1 << 8),
502 | /// PBT_IN -- Twin PBT (inside), arg float [0.0 ... 1.0]
503 | TwinPbtIn = (1 << 9),
504 | /// PBT_OUT -- Twin PBT (outside), arg float [0.0 ... 1.0]
505 | TwinPbtOut = (1 << 10),
506 | /// CWPITCH -- CW pitch, arg int (Hz)
507 | CWPitch = (1 << 11),
508 | /// RFPOWER -- RF Power, arg float [0.0 ... 1.0]
509 | RFPower = (1 << 12),
510 | /// MICGAIN -- MIC Gain, arg float [0.0 ... 1.0]
511 | MicGain = (1 << 13),
512 | /// KEYSPD -- Key Speed, arg int (WPM)
513 | KeySpeed = (1 << 14),
514 | /// NOTCHF -- Notch Freq., arg int (Hz)
515 | NotchFrequency = (1 << 15),
516 | /// COMP -- Compressor, arg float [0.0 ... 1.0]
517 | Compressor = (1 << 16),
518 | /// AGC -- AGC, arg int (see enum agc_level_e)
519 | Agc = (1 << 17),
520 | /// BKINDL -- BKin Delay, arg int (tenth of dots)
521 | BKInDelay = (1 << 18),
522 | /// BAL -- Balance (Dual Watch), arg float [0.0 ... 1.0]
523 | Balance = (1 << 19),
524 | /// METER -- Display meter, arg int (see enum meter_level_e)
525 | DisplayMeter = (1 << 20),
526 | /// VOXGAIN -- VOX gain level, arg float [0.0 ... 1.0]
527 | VoxGain = (1 << 21),
528 | /// Synonym of RIG_LEVEL_VOX
529 | VoxDelay = Vox,
530 | /// ANTIVOX -- anti-VOX level, arg float [0.0 ... 1.0]
531 | AntiVox = (1 << 22),
532 | /// SLOPE_LOW -- Slope tune, low frequency cut,
533 | SlopeLow = (1 << 23),
534 | /// SLOPE_HIGH -- Slope tune, high frequency cut,
535 | SlopeHigh = (1 << 24),
536 | /// BKIN_DLYMS -- BKin Delay, arg int Milliseconds
537 | BKInDelayMS = (1 << 25),
538 |
539 | //These are not settable
540 |
541 | /// RAWSTR -- Raw (A/D) value for signal strength, specific to each rig, arg int
542 | RIG_LEVEL_RAWSTR = (1 << 26),
543 | /// SQLSTAT -- SQL status, arg int (open=1/closed=0). Deprecated, use get_dcd instead
544 | RIG_LEVEL_SQLSTAT = (1 << 27),
545 | /// SWR -- SWR, arg float [0.0 ... infinite]
546 | Swr = (1 << 28),
547 | /// ALC -- ALC, arg float
548 | Alc = (1 << 29),
549 | /// STRENGTH -- Effective (calibrated) signal strength relative to S9, arg int (dB)
550 | RIG_LEVEL_STRENGTH = (1 << 30)
551 | /// Bandwidth Control, arg int (Hz)
552 | // RIG_LEVEL_BWC = (1<<31)
553 | }
554 |
555 | //Rig Parameters
556 | //
557 | // Parameters are settings that are not VFO specific.
558 | // STRING used in rigctl
559 | [Flags]
560 | public enum RigParm
561 | {
562 | /// '' -- No Parm
563 | None = 0,
564 | /// ANN -- "Announce" level, see ann_t
565 | Announce = (1 << 0),
566 | /// APO -- Auto power off, int in minute
567 | AutoPowerOff = (1 << 1),
568 | /// BACKLIGHT -- LCD light, float [0.0 ... 1.0]
569 | Backlight = (1 << 2),
570 | /// BEEP -- Beep on keypressed, int (0,1)
571 | Beep = (1 << 4),
572 | /// TIME -- hh:mm:ss, int in seconds from 00:00:00
573 | Time = (1 << 5),
574 | /// BAT -- battery level, float [0.0 ... 1.0]
575 | BatteryLevel = (1 << 6),
576 | /// KEYLIGHT -- Button backlight, on/off
577 | ButtonBacklight = (1 << 7)
578 | }
579 |
580 | // Rig type flags
581 | [Flags]
582 | public enum RigFlags
583 | {
584 | Other = 0,
585 | /// Receiver
586 | Receiver = (1 << 1),
587 | /// Transmitter
588 | Transmitter = (1 << 2),
589 | Transceiver = (Receiver | Transmitter),
590 | /// Scanner
591 | Scanner = (1 << 3),
592 | /// mobile sized
593 | Mobile = (1 << 4),
594 | /// handheld sized
595 | Handheld = (1 << 5),
596 | /// "Computer" rig
597 | Computer = (1 << 6),
598 | /// has trunking
599 | Trunking = (1 << 7),
600 | /// has APRS
601 | Aprs = (1 << 8),
602 | /// has TNC
603 | Tnc = (1 << 9),
604 | /// has DXCluster
605 | DXCluster = (1 << 10),
606 | /// dumb tuner
607 | Tuner = (1 << 11),
608 | Mask = (Transceiver | Scanner | Mobile | Handheld |
609 | Computer | Trunking | Tuner),
610 | }
611 |
612 | [Flags]
613 | public enum RigType
614 | {
615 | Other = 0,
616 | Transceiver = RigFlags.Transceiver,
617 | Handheld = (RigFlags.Transceiver | RigFlags.Handheld),
618 | Mobile = (RigFlags.Transceiver | RigFlags.Mobile),
619 | Receiver = RigFlags.Receiver,
620 | PCReceiver = (RigFlags.Computer | RigFlags.Receiver),
621 | Scanner = (RigFlags.Scanner | RigFlags.Receiver),
622 | TrunkScanner = (RigFlags.Scanner | RigFlags.Trunking),
623 | Computer = (RigFlags.Transceiver | RigFlags.Computer),
624 | Tuner = RigFlags.Tuner,
625 | }
626 |
627 | public enum RigConf
628 | {
629 | /// String type
630 | String,
631 | /// Combo type
632 | Combo,
633 | /// Numeric type integer or real
634 | Numeric,
635 | /// on/off type
636 | CheckButton,
637 | /// Button type
638 | Button
639 |
640 | }
641 |
642 | public enum RigTransceive
643 | {
644 | Off = 0,
645 | Rig = 1,
646 | Poll = 2,
647 | }
648 |
649 | public enum RigAgcLevel
650 | {
651 | Off = 0,
652 | Superfast,
653 | Fast,
654 | Slow,
655 | User,
656 | Medium,
657 | Auto
658 | };
659 |
660 | public static class ModeValue
661 | {
662 | public const int Any = 0;
663 | }
664 | }
665 |
--------------------------------------------------------------------------------
/x64/RigCapsNative64.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigCapsNative64.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 |
27 | namespace HamLibSharp.x64
28 | {
29 | ///
30 | /// This class holds the caps values and uses the C type "long" as 64-bit.
31 | /// This is used for 64-bit architectures (except for Windows 64)
32 | ///
33 | [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
34 | internal class RigCapsNative64 : IRigCapsNative
35 | {
36 | // max mode/filter list size, zero ended
37 | // NOTE: This was changed from 42 to 60 in version 3.0.1
38 | internal const int FLTLSTSIZ = 60;
39 |
40 | // Rig model
41 | internal int rig_model;
42 | //rig_model_t
43 |
44 | // Model name.
45 | [MarshalAs (UnmanagedType.LPStr)]
46 | internal string model_name;
47 |
48 | // Manufacturer.
49 | [MarshalAs (UnmanagedType.LPStr)]
50 | internal string mfg_name;
51 |
52 | // Driver version.
53 | [MarshalAs (UnmanagedType.LPStr)]
54 | internal string version;
55 |
56 | // Copyright info.
57 | [MarshalAs (UnmanagedType.LPStr)]
58 | internal string copyright;
59 |
60 | // Driver status.
61 | internal RigBackendStatus status;
62 |
63 | // Rig type.
64 | internal RigType rig_type;
65 | // Type of the PTT port.
66 | internal PttType ptt_type;
67 | // Type of the DCD port.
68 | internal RigDcd dcd_type;
69 | // Type of communication port.
70 | internal RigPort port_type;
71 |
72 | // Minimum serial speed.
73 | internal int serial_rate_min;
74 | // Maximum serial speed.
75 | internal int serial_rate_max;
76 | // Number of data bits.
77 | internal int serial_data_bits;
78 | // Number of stop bits.
79 | internal int serial_stop_bits;
80 |
81 | // Parity.
82 | internal RigSerialParity serial_parity;
83 | // Handshake.
84 | internal RigSerialHandshake serial_handshake;
85 |
86 | // Delay between each byte sent out, in mS
87 | internal int write_delay;
88 | // Delay between each commands send out, in mS
89 | internal int post_write_delay;
90 | // Timeout, in mS
91 | internal int timeout;
92 |
93 | // Maximum number of retries if command fails, 0 to disable
94 | internal int retry;
95 |
96 | // List of get functions
97 | internal ulong has_get_func;
98 | // List of set functions
99 | internal ulong has_set_func;
100 | // List of get level
101 | internal ulong has_get_level;
102 | // List of set level
103 | internal ulong has_set_level;
104 | // List of get parm
105 | internal ulong has_get_parm;
106 | // List of set parm
107 | internal ulong has_set_parm;
108 |
109 | // level granularity (i.e. steps)
110 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
111 | internal Granularity[] level_gran;
112 |
113 | // parm granularity (i.e. steps)
114 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
115 | internal Granularity[] parm_gran;
116 |
117 | // Extension parm list, \sa ext.c
118 |
119 | //[MarshalAs (UnmanagedType.Struct)]
120 | internal IntPtr extparms;
121 | // Extension level list, \sa ext.c
122 | //[MarshalAs (UnmanagedType.Struct)]
123 | internal IntPtr extlevels;
124 |
125 | // CTCSS tones list, zero ended
126 | internal IntPtr ctcss_list;
127 | // DCS code list, zero ended
128 | internal IntPtr dcs_list;
129 |
130 | // Preamp list in dB, 0 terminated
131 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
132 | internal int[] preamp;
133 |
134 | // Preamp list in dB, 0 terminated
135 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
136 | internal int[] attenuator;
137 |
138 | // max absolute RIT
139 | internal long max_rit;
140 | // max absolute XIT
141 | internal long max_xit;
142 | // max absolute IF-SHIFT
143 | internal long max_ifshift;
144 |
145 | // Announces bit field list
146 | internal RigAnnounce announces;
147 |
148 | // VFO op bit field list
149 | internal RigVfoOperation vfo_ops;
150 | // Scan bit field list
151 | internal RigScanOperation scan_ops;
152 | // Bit field list of direct VFO access commands
153 | internal int targetable_vfo;
154 | // Supported transceive mode
155 | internal RigTransceive transceive;
156 |
157 | // Number of banks
158 | internal int bank_qty;
159 | // Max length of memory channel name
160 | internal int chan_desc_sz;
161 |
162 | // Channel list, zero ended
163 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.CHANLSTSIZ)]
164 | internal ChannelList64[] chan_list;
165 |
166 | // Receive frequency range list for ITU region 1
167 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
168 | internal FrequencyRange[] rx_range_list1;
169 |
170 | // Transmit frequency range list for ITU region 1
171 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
172 | internal FrequencyRange[] tx_range_list1;
173 |
174 | // Receive frequency range list for ITU region 2
175 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
176 | internal FrequencyRange[] rx_range_list2;
177 |
178 | // Transmit frequency range list for ITU region 2
179 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
180 | internal FrequencyRange[] tx_range_list2;
181 |
182 | // Tuning step list
183 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.TSLSTSIZ)]
184 | internal ModeValue64[] tuning_steps;
185 |
186 | // mode/filter table, at -6dB
187 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = FLTLSTSIZ)]
188 | internal ModeValue64[] filters_list;
189 |
190 | // S-meter calibration table
191 | internal CalibrationTable str_cal;
192 |
193 | // Configuration parametres.
194 | internal IntPtr cfgparams;
195 | // Private data.
196 | internal IntPtr priv;
197 |
198 | // function pointers to API functions, if IntPtr.Zero, the function is not available
199 | internal IntPtr rig_init;
200 | internal IntPtr rig_cleanup;
201 | internal IntPtr rig_open;
202 | internal IntPtr rig_close;
203 |
204 | internal IntPtr set_freq;
205 | internal IntPtr get_freq;
206 |
207 | internal IntPtr set_mode;
208 | internal IntPtr get_mode;
209 |
210 | internal IntPtr set_vfo;
211 | internal IntPtr get_vfo;
212 |
213 | internal IntPtr set_ptt;
214 | internal IntPtr get_ptt;
215 | internal IntPtr get_dcd;
216 |
217 | internal IntPtr set_rptr_shift;
218 | internal IntPtr get_rptr_shift;
219 |
220 | internal IntPtr set_rptr_offs;
221 | internal IntPtr get_rptr_offs;
222 |
223 | internal IntPtr set_split_freq;
224 | internal IntPtr get_split_freq;
225 | internal IntPtr set_split_mode;
226 | internal IntPtr get_split_mode;
227 | internal IntPtr set_split_freq_mode;
228 | internal IntPtr get_split_freq_mode;
229 |
230 | internal IntPtr set_split_vfo;
231 | internal IntPtr get_split_vfo;
232 |
233 | internal IntPtr set_rit;
234 | internal IntPtr get_rit;
235 | internal IntPtr set_xit;
236 | internal IntPtr get_xit;
237 |
238 | internal IntPtr set_ts;
239 | internal IntPtr get_ts;
240 |
241 | internal IntPtr set_dcs_code;
242 | internal IntPtr get_dcs_code;
243 | internal IntPtr set_tone;
244 | internal IntPtr get_tone;
245 | internal IntPtr set_ctcss_tone;
246 | internal IntPtr get_ctcss_tone;
247 |
248 | internal IntPtr set_dcs_sql;
249 | internal IntPtr get_dcs_sql;
250 | internal IntPtr set_tone_sql;
251 | internal IntPtr get_tone_sql;
252 | internal IntPtr set_ctcss_sql;
253 | internal IntPtr get_ctcss_sql;
254 |
255 | internal IntPtr power2mW;
256 | internal IntPtr mW2power;
257 |
258 | internal IntPtr set_powerstat;
259 | internal IntPtr get_powerstat;
260 | internal IntPtr reset;
261 |
262 | internal IntPtr set_ant;
263 | internal IntPtr get_ant;
264 |
265 | internal IntPtr set_level;
266 | internal IntPtr get_level;
267 |
268 | internal IntPtr set_func;
269 | internal IntPtr get_func;
270 |
271 | internal IntPtr set_parm;
272 | internal IntPtr get_parm;
273 |
274 | internal IntPtr set_ext_level;
275 | internal IntPtr get_ext_level;
276 |
277 | internal IntPtr set_ext_parm;
278 | internal IntPtr get_ext_parm;
279 |
280 | internal IntPtr set_conf;
281 | internal IntPtr get_conf;
282 |
283 | internal IntPtr send_dtmf;
284 | internal IntPtr recv_dtmf;
285 | internal IntPtr send_morse;
286 |
287 | internal IntPtr set_bank;
288 | internal IntPtr set_mem;
289 | internal IntPtr get_mem;
290 | internal IntPtr vfo_op;
291 | internal IntPtr scan;
292 |
293 | internal IntPtr set_trn;
294 | internal IntPtr get_trn;
295 |
296 | internal IntPtr decode_event;
297 |
298 | internal IntPtr set_channel;
299 | internal IntPtr get_channel;
300 |
301 | internal IntPtr get_info;
302 |
303 | internal IntPtr set_chan_all_cb;
304 | internal IntPtr get_chan_all_cb;
305 |
306 | internal IntPtr set_mem_all_cb;
307 | internal IntPtr get_mem_all_cb;
308 |
309 | //[MarshalAs (UnmanagedType.LPStr)]
310 | internal IntPtr clone_combo_set;
311 |
312 | //[MarshalAs (UnmanagedType.LPStr)]
313 | internal IntPtr clone_combo_get;
314 |
315 | // Getter Properties to implement the interface
316 | public int Rig_model { get { return rig_model; } }
317 | public string Model_name { get { return model_name; } }
318 | public string Mfg_name { get { return mfg_name; } }
319 | public string Version { get { return version; } }
320 | public string Copyright { get { return copyright; } }
321 | public RigBackendStatus Status { get { return status; } }
322 | public RigType Rig_type { get { return rig_type; } }
323 | public PttType Ptt_type { get { return ptt_type; } }
324 | public RigDcd Dcd_type { get { return dcd_type; } }
325 | public RigPort Port_type { get { return port_type; } }
326 | public int Serial_rate_min { get { return serial_rate_min; } }
327 | public int Serial_rate_max { get { return serial_rate_max; } }
328 | public int Serial_data_bits { get { return serial_data_bits; } }
329 | public int Serial_stop_bits { get { return serial_stop_bits; } }
330 | public RigSerialParity Serial_parity { get { return serial_parity; } }
331 | public RigSerialHandshake Serial_handshake { get { return serial_handshake; } }
332 | public int Write_delay { get { return write_delay; } }
333 | public int Post_write_delay { get { return post_write_delay; } }
334 | public int Timeout { get { return timeout; } }
335 | public int Retry { get { return retry; } }
336 | public uint Has_get_func { get { return (uint)has_get_func; } }
337 | public uint Has_set_func { get { return (uint)has_set_func; } }
338 | public uint Has_get_level { get { return (uint)has_get_level; } }
339 | public uint Has_set_level { get { return (uint)has_set_level; } }
340 | public uint Has_get_parm { get { return (uint)has_get_parm; } }
341 | public uint Has_set_parm { get { return (uint)has_set_parm; } }
342 | public Granularity[] Level_gran { get { return level_gran; } }
343 | public Granularity[] Parm_gran { get { return parm_gran; } }
344 | public IntPtr Extparms { get { return extparms; } }
345 | public IntPtr Extlevels { get { return extlevels; } }
346 | public IntPtr Ctcss_list { get { return ctcss_list; } }
347 | public IntPtr Dcs_list { get { return dcs_list; } }
348 | public int[] Preamp { get { return preamp; } }
349 | public int[] Attenuator { get { return attenuator; } }
350 | public int Max_rit { get { return (int)max_rit; } }
351 | public int Max_xit { get { return (int)max_xit; } }
352 | public int Max_ifshift { get { return (int)max_ifshift; } }
353 | public RigAnnounce Announces { get { return announces; } }
354 | public RigVfoOperation Vfo_ops { get { return vfo_ops; } }
355 | public RigScanOperation Scan_ops { get { return scan_ops; } }
356 | public int Targetable_vfo { get { return Targetable_vfo1; } }
357 | public int Targetable_vfo1 { get { return targetable_vfo; } }
358 | public RigTransceive Transceive { get { return transceive; } }
359 | public int Bank_qty { get { return bank_qty; } }
360 | public int Chan_desc_sz { get { return chan_desc_sz; } }
361 | public IList Chan_list { get { return chan_list.CastList(); } }
362 | public FrequencyRange[] Rx_range_list1 { get { return rx_range_list1; } }
363 | public FrequencyRange[] Tx_range_list1 { get { return tx_range_list1; } }
364 | public FrequencyRange[] Rx_range_list2 { get { return rx_range_list2; } }
365 | public FrequencyRange[] Tx_range_list2 { get { return tx_range_list2; } }
366 | public IList Tuning_steps { get { return tuning_steps.CastList(); } }
367 | public IList Filters_list { get { return filters_list.CastList(); } }
368 | public CalibrationTable Str_cal { get { return str_cal; } }
369 | public IntPtr Cfgparams { get { return cfgparams; } }
370 | public IntPtr Priv { get { return priv; } }
371 | public IntPtr Rig_init { get { return rig_init; } }
372 | public IntPtr Rig_cleanup { get { return rig_cleanup; } }
373 | public IntPtr Rig_open { get { return rig_open; } }
374 | public IntPtr Rig_close { get { return rig_close; } }
375 | public IntPtr Set_freq { get { return set_freq; } }
376 | public IntPtr Get_freq { get { return get_freq; } }
377 | public IntPtr Set_mode { get { return set_mode; } }
378 | public IntPtr Get_mode { get { return get_mode; } }
379 | public IntPtr Set_vfo { get { return set_vfo; } }
380 | public IntPtr Get_vfo { get { return get_vfo; } }
381 | public IntPtr Set_ptt { get { return set_ptt; } }
382 | public IntPtr Get_ptt { get { return get_ptt; } }
383 | public IntPtr Get_dcd { get { return get_dcd; } }
384 | public IntPtr Set_rptr_shift { get { return set_rptr_shift; } }
385 | public IntPtr Get_rptr_shift { get { return get_rptr_shift; } }
386 | public IntPtr Set_rptr_offs { get { return set_rptr_offs; } }
387 | public IntPtr Get_rptr_offs { get { return get_rptr_offs; } }
388 | public IntPtr Set_split_freq { get { return set_split_freq; } }
389 | public IntPtr Get_split_freq { get { return get_split_freq; } }
390 | public IntPtr Set_split_mode { get { return set_split_mode; } }
391 | public IntPtr Get_split_mode { get { return get_split_mode; } }
392 | public IntPtr Set_split_freq_mode { get { return set_split_freq_mode; } }
393 | public IntPtr Get_split_freq_mode { get { return get_split_freq_mode; } }
394 | public IntPtr Set_split_vfo { get { return set_split_vfo; } }
395 | public IntPtr Get_split_vfo { get { return get_split_vfo; } }
396 | public IntPtr Set_rit { get { return set_rit; } }
397 | public IntPtr Get_rit { get { return get_rit; } }
398 | public IntPtr Set_xit { get { return set_xit; } }
399 | public IntPtr Get_xit { get { return get_xit; } }
400 | public IntPtr Set_ts { get { return set_ts; } }
401 | public IntPtr Get_ts { get { return get_ts; } }
402 | public IntPtr Set_dcs_code { get { return set_dcs_code; } }
403 | public IntPtr Get_dcs_code { get { return get_dcs_code; } }
404 | public IntPtr Set_tone { get { return set_tone; } }
405 | public IntPtr Get_tone { get { return get_tone; } }
406 | public IntPtr Set_ctcss_tone { get { return set_ctcss_tone; } }
407 | public IntPtr Get_ctcss_tone { get { return get_ctcss_tone; } }
408 | public IntPtr Set_dcs_sql { get { return set_dcs_sql; } }
409 | public IntPtr Get_dcs_sql { get { return get_dcs_sql; } }
410 | public IntPtr Set_tone_sql { get { return set_tone_sql; } }
411 | public IntPtr Get_tone_sql { get { return get_tone_sql; } }
412 | public IntPtr Set_ctcss_sql { get { return set_ctcss_sql; } }
413 | public IntPtr Get_ctcss_sql { get { return get_ctcss_sql; } }
414 | public IntPtr Power2mW { get { return power2mW; } }
415 | public IntPtr MW2power { get { return mW2power; } }
416 | public IntPtr Set_powerstat { get { return set_powerstat; } }
417 | public IntPtr Get_powerstat { get { return get_powerstat; } }
418 | public IntPtr Reset { get { return reset; } }
419 | public IntPtr Set_ant { get { return set_ant; } }
420 | public IntPtr Get_ant { get { return get_ant; } }
421 | public IntPtr Set_level { get { return set_level; } }
422 | public IntPtr Get_level { get { return get_level; } }
423 | public IntPtr Set_func { get { return set_func; } }
424 | public IntPtr Get_func { get { return get_func; } }
425 | public IntPtr Set_parm { get { return set_parm; } }
426 | public IntPtr Get_parm { get { return get_parm; } }
427 | public IntPtr Set_ext_level { get { return set_ext_level; } }
428 | public IntPtr Get_ext_level { get { return get_ext_level; } }
429 | public IntPtr Set_ext_parm { get { return set_ext_parm; } }
430 | public IntPtr Get_ext_parm { get { return get_ext_parm; } }
431 | public IntPtr Set_conf { get { return set_conf; } }
432 | public IntPtr Get_conf { get { return get_conf; } }
433 | public IntPtr Send_dtmf { get { return send_dtmf; } }
434 | public IntPtr Recv_dtmf { get { return recv_dtmf; } }
435 | public IntPtr Send_morse { get { return send_morse; } }
436 | public IntPtr Set_bank { get { return set_bank; } }
437 | public IntPtr Set_mem { get { return set_mem; } }
438 | public IntPtr Get_mem { get { return get_mem; } }
439 | public IntPtr Vfo_op { get { return vfo_op; } }
440 | public IntPtr Scan { get { return scan; } }
441 | public IntPtr Set_trn { get { return set_trn; } }
442 | public IntPtr Get_trn { get { return get_trn; } }
443 | public IntPtr Decode_event { get { return decode_event; } }
444 | public IntPtr Set_channel { get { return set_channel; } }
445 | public IntPtr Get_channel { get { return get_channel; } }
446 | public IntPtr Get_info { get { return get_info; } }
447 | public IntPtr Set_chan_all_cb { get { return set_chan_all_cb; } }
448 | public IntPtr Get_chan_all_cb { get { return get_chan_all_cb; } }
449 | public IntPtr Set_mem_all_cb { get { return set_mem_all_cb; } }
450 | public IntPtr Get_mem_all_cb { get { return get_mem_all_cb; } }
451 | public IntPtr Clone_combo_set { get { return clone_combo_set; } }
452 | public IntPtr Clone_combo_get { get { return clone_combo_get; } }
453 | }
454 | }
455 |
--------------------------------------------------------------------------------
/x86/RigCapsNative32.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigCapsNative32.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 |
27 | namespace HamLibSharp.x86
28 | {
29 | ///
30 | /// This class holds the caps values and uses the C type "long" as 32-bit.
31 | /// This is used for 32-bit architectures and all Windows architectures (32 and 64 bit)
32 | ///
33 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
34 | internal class RigCapsNative32 : IRigCapsNative
35 | {
36 | // max mode/filter list size, zero ended
37 | // NOTE: This was changed from 42 to 60 in version 3.0.1
38 | internal const int FLTLSTSIZ = 60;
39 |
40 | // Rig model
41 | private int rig_model;
42 | //rig_model_t
43 |
44 | // Model name.
45 | [MarshalAs(UnmanagedType.LPStr)]
46 | private string model_name;
47 |
48 | // Manufacturer.
49 | [MarshalAs(UnmanagedType.LPStr)]
50 | private string mfg_name;
51 |
52 | // Driver version.
53 | [MarshalAs(UnmanagedType.LPStr)]
54 | private string version;
55 |
56 | // Copyright info.
57 | [MarshalAs(UnmanagedType.LPStr)]
58 | private string copyright;
59 |
60 | // Driver status.
61 | private RigBackendStatus status;
62 |
63 | // Rig type.
64 | private RigType rig_type;
65 | // Type of the PTT port.
66 | private PttType ptt_type;
67 | // Type of the DCD port.
68 | private RigDcd dcd_type;
69 | // Type of communication port.
70 | private RigPort port_type;
71 |
72 | // Minimum serial speed.
73 | private int serial_rate_min;
74 | // Maximum serial speed.
75 | private int serial_rate_max;
76 | // Number of data bits.
77 | private int serial_data_bits;
78 | // Number of stop bits.
79 | private int serial_stop_bits;
80 |
81 | // Parity.
82 | private RigSerialParity serial_parity;
83 | // Handshake.
84 | private RigSerialHandshake serial_handshake;
85 |
86 | // Delay between each byte sent out, in mS
87 | private int write_delay;
88 | // Delay between each commands send out, in mS
89 | private int post_write_delay;
90 | // Timeout, in mS
91 | private int timeout;
92 |
93 | // Maximum number of retries if command fails, 0 to disable
94 | private int retry;
95 |
96 | // List of get functions
97 | private uint has_get_func;
98 | // List of set functions
99 | private uint has_set_func;
100 | // List of get level
101 | private uint has_get_level;
102 | // List of set level
103 | private uint has_set_level;
104 | // List of get parm
105 | private uint has_get_parm;
106 | // List of set parm
107 | private uint has_set_parm;
108 |
109 | // level granularity (i.e. steps)
110 | [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
111 | private Granularity[] level_gran;
112 |
113 | // parm granularity (i.e. steps)
114 | [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
115 | private Granularity[] parm_gran;
116 |
117 | // Extension parm list, \sa ext.c
118 |
119 | //[MarshalAs (UnmanagedType.Struct)]
120 | private IntPtr extparms;
121 | // Extension level list, \sa ext.c
122 | //[MarshalAs (UnmanagedType.Struct)]
123 | private IntPtr extlevels;
124 |
125 | // CTCSS tones list, zero ended
126 | private IntPtr ctcss_list;
127 | // DCS code list, zero ended
128 | private IntPtr dcs_list;
129 |
130 | // Preamp list in dB, 0 terminated
131 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
132 | private int[] preamp;
133 |
134 | // Preamp list in dB, 0 terminated
135 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
136 | private int[] attenuator;
137 |
138 | // max absolute RIT
139 | private int max_rit;
140 | // max absolute XIT
141 | private int max_xit;
142 | // max absolute IF-SHIFT
143 | private int max_ifshift;
144 |
145 | // Announces bit field list
146 | private RigAnnounce announces;
147 |
148 | // VFO op bit field list
149 | private RigVfoOperation vfo_ops;
150 | // Scan bit field list
151 | private RigScanOperation scan_ops;
152 | // Bit field list of direct VFO access commands
153 | private int targetable_vfo;
154 | // Supported transceive mode
155 | private RigTransceive transceive;
156 |
157 | // Number of banks
158 | private int bank_qty;
159 | // Max length of memory channel name
160 | private int chan_desc_sz;
161 |
162 | // Channel list, zero ended
163 | [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.CHANLSTSIZ)]
164 | private ChannelList32[] chan_list;
165 |
166 | // Receive frequency range list for ITU region 1
167 | [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
168 | private FrequencyRange[] rx_range_list1;
169 |
170 | // Transmit frequency range list for ITU region 1
171 | [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
172 | private FrequencyRange[] tx_range_list1;
173 |
174 | // Receive frequency range list for ITU region 2
175 | [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
176 | private FrequencyRange[] rx_range_list2;
177 |
178 | // Transmit frequency range list for ITU region 2
179 | [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
180 | private FrequencyRange[] tx_range_list2;
181 |
182 | // Tuning step list
183 | [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.TSLSTSIZ)]
184 | private ModeValue32[] tuning_steps;
185 |
186 | // mode/filter table, at -6dB
187 | [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = FLTLSTSIZ)]
188 | private ModeValue32[] filters_list;
189 |
190 | // S-meter calibration table
191 | private CalibrationTable str_cal;
192 |
193 | // Configuration parametres.
194 | private IntPtr cfgparams;
195 | // Private data.
196 | private IntPtr priv;
197 |
198 | // function pointers to API functions, if IntPtr.Zero, the function is not available
199 | private IntPtr rig_init;
200 | private IntPtr rig_cleanup;
201 | private IntPtr rig_open;
202 | private IntPtr rig_close;
203 |
204 | private IntPtr set_freq;
205 | private IntPtr get_freq;
206 |
207 | private IntPtr set_mode;
208 | private IntPtr get_mode;
209 |
210 | private IntPtr set_vfo;
211 | private IntPtr get_vfo;
212 |
213 | private IntPtr set_ptt;
214 | private IntPtr get_ptt;
215 | private IntPtr get_dcd;
216 |
217 | private IntPtr set_rptr_shift;
218 | private IntPtr get_rptr_shift;
219 |
220 | private IntPtr set_rptr_offs;
221 | private IntPtr get_rptr_offs;
222 |
223 | private IntPtr set_split_freq;
224 | private IntPtr get_split_freq;
225 | private IntPtr set_split_mode;
226 | private IntPtr get_split_mode;
227 | private IntPtr set_split_freq_mode;
228 | private IntPtr get_split_freq_mode;
229 |
230 | private IntPtr set_split_vfo;
231 | private IntPtr get_split_vfo;
232 |
233 | private IntPtr set_rit;
234 | private IntPtr get_rit;
235 | private IntPtr set_xit;
236 | private IntPtr get_xit;
237 |
238 | private IntPtr set_ts;
239 | private IntPtr get_ts;
240 |
241 | private IntPtr set_dcs_code;
242 | private IntPtr get_dcs_code;
243 | private IntPtr set_tone;
244 | private IntPtr get_tone;
245 | private IntPtr set_ctcss_tone;
246 | private IntPtr get_ctcss_tone;
247 |
248 | private IntPtr set_dcs_sql;
249 | private IntPtr get_dcs_sql;
250 | private IntPtr set_tone_sql;
251 | private IntPtr get_tone_sql;
252 | private IntPtr set_ctcss_sql;
253 | private IntPtr get_ctcss_sql;
254 |
255 | private IntPtr power2mW;
256 | private IntPtr mW2power;
257 |
258 | private IntPtr set_powerstat;
259 | private IntPtr get_powerstat;
260 | private IntPtr reset;
261 |
262 | private IntPtr set_ant;
263 | private IntPtr get_ant;
264 |
265 | private IntPtr set_level;
266 | private IntPtr get_level;
267 |
268 | private IntPtr set_func;
269 | private IntPtr get_func;
270 |
271 | private IntPtr set_parm;
272 | private IntPtr get_parm;
273 |
274 | private IntPtr set_ext_level;
275 | private IntPtr get_ext_level;
276 |
277 | private IntPtr set_ext_parm;
278 | private IntPtr get_ext_parm;
279 |
280 | private IntPtr set_conf;
281 | private IntPtr get_conf;
282 |
283 | private IntPtr send_dtmf;
284 | private IntPtr recv_dtmf;
285 | private IntPtr send_morse;
286 |
287 | private IntPtr set_bank;
288 | private IntPtr set_mem;
289 | private IntPtr get_mem;
290 | private IntPtr vfo_op;
291 | private IntPtr scan;
292 |
293 | private IntPtr set_trn;
294 | private IntPtr get_trn;
295 |
296 | private IntPtr decode_event;
297 |
298 | private IntPtr set_channel;
299 | private IntPtr get_channel;
300 |
301 | private IntPtr get_info;
302 |
303 | private IntPtr set_chan_all_cb;
304 | private IntPtr get_chan_all_cb;
305 |
306 | private IntPtr set_mem_all_cb;
307 | private IntPtr get_mem_all_cb;
308 |
309 | //[MarshalAs (UnmanagedType.LPStr)]
310 | private IntPtr clone_combo_set;
311 |
312 | //[MarshalAs (UnmanagedType.LPStr)]
313 | private IntPtr clone_combo_get;
314 |
315 | private int test1;
316 | private int test2;
317 | private int test3;
318 | private int test4;
319 | private int test5;
320 | private int test6;
321 | private int test7;
322 | private int test8;
323 | private int test9;
324 | private int test10;
325 |
326 | // Getter Properties to implement the interface
327 | public int Rig_model { get { return rig_model; } }
328 | public string Model_name { get { return model_name; } }
329 | public string Mfg_name { get { return mfg_name; } }
330 | public string Version { get { return version; } }
331 | public string Copyright { get { return copyright; } }
332 | public RigBackendStatus Status { get { return status; } }
333 | public RigType Rig_type { get { return rig_type; } }
334 | public PttType Ptt_type { get { return ptt_type; } }
335 | public RigDcd Dcd_type { get { return dcd_type; } }
336 | public RigPort Port_type { get { return port_type; } }
337 | public int Serial_rate_min { get { return serial_rate_min; } }
338 | public int Serial_rate_max { get { return serial_rate_max; } }
339 | public int Serial_data_bits { get { return serial_data_bits; } }
340 | public int Serial_stop_bits { get { return serial_stop_bits; } }
341 | public RigSerialParity Serial_parity { get { return serial_parity; } }
342 | public RigSerialHandshake Serial_handshake { get { return serial_handshake; } }
343 | public int Write_delay { get { return write_delay; } }
344 | public int Post_write_delay { get { return post_write_delay; } }
345 | public int Timeout { get { return timeout; } }
346 | public int Retry { get { return retry; } }
347 | public uint Has_get_func { get { return has_get_func; } }
348 | public uint Has_set_func { get { return has_set_func; } }
349 | public uint Has_get_level { get { return has_get_level; } }
350 | public uint Has_set_level { get { return has_set_level; } }
351 | public uint Has_get_parm { get { return has_get_parm; } }
352 | public uint Has_set_parm { get { return has_set_parm; } }
353 | public Granularity[] Level_gran { get { return level_gran; } }
354 | public Granularity[] Parm_gran { get { return parm_gran; } }
355 | public IntPtr Extparms { get { return extparms; } }
356 | public IntPtr Extlevels { get { return extlevels; } }
357 | public IntPtr Ctcss_list { get { return ctcss_list; } }
358 | public IntPtr Dcs_list { get { return dcs_list; } }
359 | public int[] Preamp { get { return preamp; } }
360 | public int[] Attenuator { get { return attenuator; } }
361 | public int Max_rit { get { return max_rit; } }
362 | public int Max_xit { get { return max_xit; } }
363 | public int Max_ifshift { get { return max_ifshift; } }
364 | public RigAnnounce Announces { get { return announces; } }
365 | public RigVfoOperation Vfo_ops { get { return vfo_ops; } }
366 | public RigScanOperation Scan_ops { get { return scan_ops; } }
367 | public int Targetable_vfo { get { return Targetable_vfo1; } }
368 | public int Targetable_vfo1 { get { return targetable_vfo; } }
369 | public RigTransceive Transceive { get { return transceive; } }
370 | public int Bank_qty { get { return bank_qty; } }
371 | public int Chan_desc_sz { get { return chan_desc_sz; } }
372 | public IList Chan_list { get { return chan_list.CastList(); } }
373 | public FrequencyRange[] Rx_range_list1 { get { return rx_range_list1; } }
374 | public FrequencyRange[] Tx_range_list1 { get { return tx_range_list1; } }
375 | public FrequencyRange[] Rx_range_list2 { get { return rx_range_list2; } }
376 | public FrequencyRange[] Tx_range_list2 { get { return tx_range_list2; } }
377 | public IList Tuning_steps { get { return tuning_steps.CastList(); } }
378 | public IList Filters_list { get { return filters_list.CastList(); } }
379 | public CalibrationTable Str_cal { get { return str_cal; } }
380 | public IntPtr Cfgparams { get { return cfgparams; } }
381 | public IntPtr Priv { get { return priv; } }
382 | public IntPtr Rig_init { get { return rig_init; } }
383 | public IntPtr Rig_cleanup { get { return rig_cleanup; } }
384 | public IntPtr Rig_open { get { return rig_open; } }
385 | public IntPtr Rig_close { get { return rig_close; } }
386 | public IntPtr Set_freq { get { return set_freq; } }
387 | public IntPtr Get_freq { get { return get_freq; } }
388 | public IntPtr Set_mode { get { return set_mode; } }
389 | public IntPtr Get_mode { get { return get_mode; } }
390 | public IntPtr Set_vfo { get { return set_vfo; } }
391 | public IntPtr Get_vfo { get { return get_vfo; } }
392 | public IntPtr Set_ptt { get { return set_ptt; } }
393 | public IntPtr Get_ptt { get { return get_ptt; } }
394 | public IntPtr Get_dcd { get { return get_dcd; } }
395 | public IntPtr Set_rptr_shift { get { return set_rptr_shift; } }
396 | public IntPtr Get_rptr_shift { get { return get_rptr_shift; } }
397 | public IntPtr Set_rptr_offs { get { return set_rptr_offs; } }
398 | public IntPtr Get_rptr_offs { get { return get_rptr_offs; } }
399 | public IntPtr Set_split_freq { get { return set_split_freq; } }
400 | public IntPtr Get_split_freq { get { return get_split_freq; } }
401 | public IntPtr Set_split_mode { get { return set_split_mode; } }
402 | public IntPtr Get_split_mode { get { return get_split_mode; } }
403 | public IntPtr Set_split_freq_mode { get { return set_split_freq_mode; } }
404 | public IntPtr Get_split_freq_mode { get { return get_split_freq_mode; } }
405 | public IntPtr Set_split_vfo { get { return set_split_vfo; } }
406 | public IntPtr Get_split_vfo { get { return get_split_vfo; } }
407 | public IntPtr Set_rit { get { return set_rit; } }
408 | public IntPtr Get_rit { get { return get_rit; } }
409 | public IntPtr Set_xit { get { return set_xit; } }
410 | public IntPtr Get_xit { get { return get_xit; } }
411 | public IntPtr Set_ts { get { return set_ts; } }
412 | public IntPtr Get_ts { get { return get_ts; } }
413 | public IntPtr Set_dcs_code { get { return set_dcs_code; } }
414 | public IntPtr Get_dcs_code { get { return get_dcs_code; } }
415 | public IntPtr Set_tone { get { return set_tone; } }
416 | public IntPtr Get_tone { get { return get_tone; } }
417 | public IntPtr Set_ctcss_tone { get { return set_ctcss_tone; } }
418 | public IntPtr Get_ctcss_tone { get { return get_ctcss_tone; } }
419 | public IntPtr Set_dcs_sql { get { return set_dcs_sql; } }
420 | public IntPtr Get_dcs_sql { get { return get_dcs_sql; } }
421 | public IntPtr Set_tone_sql { get { return set_tone_sql; } }
422 | public IntPtr Get_tone_sql { get { return get_tone_sql; } }
423 | public IntPtr Set_ctcss_sql { get { return set_ctcss_sql; } }
424 | public IntPtr Get_ctcss_sql { get { return get_ctcss_sql; } }
425 | public IntPtr Power2mW { get { return power2mW; } }
426 | public IntPtr MW2power { get { return mW2power; } }
427 | public IntPtr Set_powerstat { get { return set_powerstat; } }
428 | public IntPtr Get_powerstat { get { return get_powerstat; } }
429 | public IntPtr Reset { get { return reset; } }
430 | public IntPtr Set_ant { get { return set_ant; } }
431 | public IntPtr Get_ant { get { return get_ant; } }
432 | public IntPtr Set_level { get { return set_level; } }
433 | public IntPtr Get_level { get { return get_level; } }
434 | public IntPtr Set_func { get { return set_func; } }
435 | public IntPtr Get_func { get { return get_func; } }
436 | public IntPtr Set_parm { get { return set_parm; } }
437 | public IntPtr Get_parm { get { return get_parm; } }
438 | public IntPtr Set_ext_level { get { return set_ext_level; } }
439 | public IntPtr Get_ext_level { get { return get_ext_level; } }
440 | public IntPtr Set_ext_parm { get { return set_ext_parm; } }
441 | public IntPtr Get_ext_parm { get { return get_ext_parm; } }
442 | public IntPtr Set_conf { get { return set_conf; } }
443 | public IntPtr Get_conf { get { return get_conf; } }
444 | public IntPtr Send_dtmf { get { return send_dtmf; } }
445 | public IntPtr Recv_dtmf { get { return recv_dtmf; } }
446 | public IntPtr Send_morse { get { return send_morse; } }
447 | public IntPtr Set_bank { get { return set_bank; } }
448 | public IntPtr Set_mem { get { return set_mem; } }
449 | public IntPtr Get_mem { get { return get_mem; } }
450 | public IntPtr Vfo_op { get { return vfo_op; } }
451 | public IntPtr Scan { get { return scan; } }
452 | public IntPtr Set_trn { get { return set_trn; } }
453 | public IntPtr Get_trn { get { return get_trn; } }
454 | public IntPtr Decode_event { get { return decode_event; } }
455 | public IntPtr Set_channel { get { return set_channel; } }
456 | public IntPtr Get_channel { get { return get_channel; } }
457 | public IntPtr Get_info { get { return get_info; } }
458 | public IntPtr Set_chan_all_cb { get { return set_chan_all_cb; } }
459 | public IntPtr Get_chan_all_cb { get { return get_chan_all_cb; } }
460 | public IntPtr Set_mem_all_cb { get { return set_mem_all_cb; } }
461 | public IntPtr Get_mem_all_cb { get { return get_mem_all_cb; } }
462 | public IntPtr Clone_combo_set { get { return clone_combo_set; } }
463 | public IntPtr Clone_combo_get { get { return clone_combo_get; } }
464 | }
465 | }
466 |
--------------------------------------------------------------------------------
/x64/RigCapsNative64v2.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RigCapsNative64v2.cs
3 | //
4 | // Author:
5 | // Jae Stutzman
6 | //
7 | // Copyright (c) 2016 Jae Stutzman
8 | //
9 | // This library is free software; you can redistribute it and/or modify
10 | // it under the terms of the GNU Lesser General Public License as
11 | // published by the Free Software Foundation; either version 2.1 of the
12 | // License, or (at your option) any later version.
13 | //
14 | // This library is distributed in the hope that it will be useful, but
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | // Lesser General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU Lesser General Public
20 | // License along with this library; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Runtime.InteropServices;
26 |
27 | namespace HamLibSharp.x64
28 | {
29 | ///
30 | /// This class holds the caps values and uses the C type "long" as 64-bit.
31 | /// This is used for 64-bit architectures (except for Windows 64)
32 | ///
33 | [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
34 | internal class RigCapsNative64v2 : IRigCapsNative
35 | {
36 | // max mode/filter list size, zero ended
37 | // NOTE: This was changed from 42 to 60 in version 3.0.1
38 | internal const int FLTLSTSIZ = 42;
39 |
40 | // Rig model
41 | internal int rig_model;
42 | //rig_model_t
43 |
44 | // Model name.
45 | [MarshalAs (UnmanagedType.LPStr)]
46 | internal string model_name;
47 |
48 | // Manufacturer.
49 | [MarshalAs (UnmanagedType.LPStr)]
50 | internal string mfg_name;
51 |
52 | // Driver version.
53 | [MarshalAs (UnmanagedType.LPStr)]
54 | internal string version;
55 |
56 | // Copyright info.
57 | [MarshalAs (UnmanagedType.LPStr)]
58 | internal string copyright;
59 |
60 | // Driver status.
61 | internal RigBackendStatus status;
62 |
63 | // Rig type.
64 | internal RigType rig_type;
65 | // Type of the PTT port.
66 | internal PttType ptt_type;
67 | // Type of the DCD port.
68 | internal RigDcd dcd_type;
69 | // Type of communication port.
70 | internal RigPort port_type;
71 |
72 | // Minimum serial speed.
73 | internal int serial_rate_min;
74 | // Maximum serial speed.
75 | internal int serial_rate_max;
76 | // Number of data bits.
77 | internal int serial_data_bits;
78 | // Number of stop bits.
79 | internal int serial_stop_bits;
80 |
81 | // Parity.
82 | internal RigSerialParity serial_parity;
83 | // Handshake.
84 | internal RigSerialHandshake serial_handshake;
85 |
86 | // Delay between each byte sent out, in mS
87 | internal int write_delay;
88 | // Delay between each commands send out, in mS
89 | internal int post_write_delay;
90 | // Timeout, in mS
91 | internal int timeout;
92 |
93 | // Maximum number of retries if command fails, 0 to disable
94 | internal int retry;
95 |
96 | // List of get functions
97 | internal ulong has_get_func;
98 | // List of set functions
99 | internal ulong has_set_func;
100 | // List of get level
101 | internal ulong has_get_level;
102 | // List of set level
103 | internal ulong has_set_level;
104 | // List of get parm
105 | internal ulong has_get_parm;
106 | // List of set parm
107 | internal ulong has_set_parm;
108 |
109 | // level granularity (i.e. steps)
110 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
111 | internal Granularity[] level_gran;
112 |
113 | // parm granularity (i.e. steps)
114 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.RIG_SETTING_MAX)]
115 | internal Granularity[] parm_gran;
116 |
117 | // Extension parm list, \sa ext.c
118 |
119 | //[MarshalAs (UnmanagedType.Struct)]
120 | internal IntPtr extparms;
121 | // Extension level list, \sa ext.c
122 | //[MarshalAs (UnmanagedType.Struct)]
123 | internal IntPtr extlevels;
124 |
125 | // CTCSS tones list, zero ended
126 | internal IntPtr ctcss_list;
127 | // DCS code list, zero ended
128 | internal IntPtr dcs_list;
129 |
130 | // Preamp list in dB, 0 terminated
131 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
132 | internal int[] preamp;
133 |
134 | // Preamp list in dB, 0 terminated
135 | [MarshalAs (UnmanagedType.ByValArray, SizeConst = Rig.MAXDBLSTSIZ)]
136 | internal int[] attenuator;
137 |
138 | // max absolute RIT
139 | internal long max_rit;
140 | // max absolute XIT
141 | internal long max_xit;
142 | // max absolute IF-SHIFT
143 | internal long max_ifshift;
144 |
145 | // Announces bit field list
146 | internal RigAnnounce announces;
147 |
148 | // VFO op bit field list
149 | internal RigVfoOperation vfo_ops;
150 | // Scan bit field list
151 | internal RigScanOperation scan_ops;
152 | // Bit field list of direct VFO access commands
153 | internal int targetable_vfo;
154 | // Supported transceive mode
155 | internal RigTransceive transceive;
156 |
157 | // Number of banks
158 | internal int bank_qty;
159 | // Max length of memory channel name
160 | internal int chan_desc_sz;
161 |
162 | // Channel list, zero ended
163 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.CHANLSTSIZ)]
164 | internal ChannelList64[] chan_list;
165 |
166 | // Receive frequency range list for ITU region 1
167 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
168 | internal FrequencyRange[] rx_range_list1;
169 |
170 | // Transmit frequency range list for ITU region 1
171 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
172 | internal FrequencyRange[] tx_range_list1;
173 |
174 | // Receive frequency range list for ITU region 2
175 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
176 | internal FrequencyRange[] rx_range_list2;
177 |
178 | // Transmit frequency range list for ITU region 2
179 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.FRQRANGESIZ)]
180 | internal FrequencyRange[] tx_range_list2;
181 |
182 | // Tuning step list
183 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.TSLSTSIZ)]
184 | internal ModeValue64[] tuning_steps;
185 |
186 | // mode/filter table, at -6dB
187 | [MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = FLTLSTSIZ)]
188 | internal ModeValue64[] filters_list;
189 |
190 | // S-meter calibration table
191 | internal CalibrationTable str_cal;
192 |
193 | // Configuration parametres.
194 | internal IntPtr cfgparams;
195 | // Private data.
196 | internal IntPtr priv;
197 |
198 | // function pointers to API functions, if IntPtr.Zero, the function is not available
199 | internal IntPtr rig_init;
200 | internal IntPtr rig_cleanup;
201 | internal IntPtr rig_open;
202 | internal IntPtr rig_close;
203 |
204 | internal IntPtr set_freq;
205 | internal IntPtr get_freq;
206 |
207 | internal IntPtr set_mode;
208 | internal IntPtr get_mode;
209 |
210 | internal IntPtr set_vfo;
211 | internal IntPtr get_vfo;
212 |
213 | internal IntPtr set_ptt;
214 | internal IntPtr get_ptt;
215 | internal IntPtr get_dcd;
216 |
217 | internal IntPtr set_rptr_shift;
218 | internal IntPtr get_rptr_shift;
219 |
220 | internal IntPtr set_rptr_offs;
221 | internal IntPtr get_rptr_offs;
222 |
223 | internal IntPtr set_split_freq;
224 | internal IntPtr get_split_freq;
225 | internal IntPtr set_split_mode;
226 | internal IntPtr get_split_mode;
227 |
228 | // This was added in 3.1
229 | //internal IntPtr set_split_freq_mode;
230 | //internal IntPtr get_split_freq_mode;
231 |
232 | internal IntPtr set_split_vfo;
233 | internal IntPtr get_split_vfo;
234 |
235 | internal IntPtr set_rit;
236 | internal IntPtr get_rit;
237 | internal IntPtr set_xit;
238 | internal IntPtr get_xit;
239 |
240 | internal IntPtr set_ts;
241 | internal IntPtr get_ts;
242 |
243 | internal IntPtr set_dcs_code;
244 | internal IntPtr get_dcs_code;
245 | internal IntPtr set_tone;
246 | internal IntPtr get_tone;
247 | internal IntPtr set_ctcss_tone;
248 | internal IntPtr get_ctcss_tone;
249 |
250 | internal IntPtr set_dcs_sql;
251 | internal IntPtr get_dcs_sql;
252 | internal IntPtr set_tone_sql;
253 | internal IntPtr get_tone_sql;
254 | internal IntPtr set_ctcss_sql;
255 | internal IntPtr get_ctcss_sql;
256 |
257 | internal IntPtr power2mW;
258 | internal IntPtr mW2power;
259 |
260 | internal IntPtr set_powerstat;
261 | internal IntPtr get_powerstat;
262 | internal IntPtr reset;
263 |
264 | internal IntPtr set_ant;
265 | internal IntPtr get_ant;
266 |
267 | internal IntPtr set_level;
268 | internal IntPtr get_level;
269 |
270 | internal IntPtr set_func;
271 | internal IntPtr get_func;
272 |
273 | internal IntPtr set_parm;
274 | internal IntPtr get_parm;
275 |
276 | internal IntPtr set_ext_level;
277 | internal IntPtr get_ext_level;
278 |
279 | internal IntPtr set_ext_parm;
280 | internal IntPtr get_ext_parm;
281 |
282 | internal IntPtr set_conf;
283 | internal IntPtr get_conf;
284 |
285 | internal IntPtr send_dtmf;
286 | internal IntPtr recv_dtmf;
287 | internal IntPtr send_morse;
288 |
289 | internal IntPtr set_bank;
290 | internal IntPtr set_mem;
291 | internal IntPtr get_mem;
292 | internal IntPtr vfo_op;
293 | internal IntPtr scan;
294 |
295 | internal IntPtr set_trn;
296 | internal IntPtr get_trn;
297 |
298 | internal IntPtr decode_event;
299 |
300 | internal IntPtr set_channel;
301 | internal IntPtr get_channel;
302 |
303 | internal IntPtr get_info;
304 |
305 | internal IntPtr set_chan_all_cb;
306 | internal IntPtr get_chan_all_cb;
307 |
308 | internal IntPtr set_mem_all_cb;
309 | internal IntPtr get_mem_all_cb;
310 |
311 | //[MarshalAs (UnmanagedType.LPStr)]
312 | internal IntPtr clone_combo_set;
313 |
314 | //[MarshalAs (UnmanagedType.LPStr)]
315 | internal IntPtr clone_combo_get;
316 |
317 | // Getter Properties to implement the interface
318 | public int Rig_model { get { return rig_model; } }
319 | public string Model_name { get { return model_name; } }
320 | public string Mfg_name { get { return mfg_name; } }
321 | public string Version { get { return version; } }
322 | public string Copyright { get { return copyright; } }
323 | public RigBackendStatus Status { get { return status; } }
324 | public RigType Rig_type { get { return rig_type; } }
325 | public PttType Ptt_type { get { return ptt_type; } }
326 | public RigDcd Dcd_type { get { return dcd_type; } }
327 | public RigPort Port_type { get { return port_type; } }
328 | public int Serial_rate_min { get { return serial_rate_min; } }
329 | public int Serial_rate_max { get { return serial_rate_max; } }
330 | public int Serial_data_bits { get { return serial_data_bits; } }
331 | public int Serial_stop_bits { get { return serial_stop_bits; } }
332 | public RigSerialParity Serial_parity { get { return serial_parity; } }
333 | public RigSerialHandshake Serial_handshake { get { return serial_handshake; } }
334 | public int Write_delay { get { return write_delay; } }
335 | public int Post_write_delay { get { return post_write_delay; } }
336 | public int Timeout { get { return timeout; } }
337 | public int Retry { get { return retry; } }
338 | public uint Has_get_func { get { return (uint)has_get_func; } }
339 | public uint Has_set_func { get { return (uint)has_set_func; } }
340 | public uint Has_get_level { get { return (uint)has_get_level; } }
341 | public uint Has_set_level { get { return (uint)has_set_level; } }
342 | public uint Has_get_parm { get { return (uint)has_get_parm; } }
343 | public uint Has_set_parm { get { return (uint)has_set_parm; } }
344 | public Granularity[] Level_gran { get { return level_gran; } }
345 | public Granularity[] Parm_gran { get { return parm_gran; } }
346 | public IntPtr Extparms { get { return extparms; } }
347 | public IntPtr Extlevels { get { return extlevels; } }
348 | public IntPtr Ctcss_list { get { return ctcss_list; } }
349 | public IntPtr Dcs_list { get { return dcs_list; } }
350 | public int[] Preamp { get { return preamp; } }
351 | public int[] Attenuator { get { return attenuator; } }
352 | public int Max_rit { get { return (int)max_rit; } }
353 | public int Max_xit { get { return (int)max_xit; } }
354 | public int Max_ifshift { get { return (int)max_ifshift; } }
355 | public RigAnnounce Announces { get { return announces; } }
356 | public RigVfoOperation Vfo_ops { get { return vfo_ops; } }
357 | public RigScanOperation Scan_ops { get { return scan_ops; } }
358 | public int Targetable_vfo { get { return Targetable_vfo1; } }
359 | public int Targetable_vfo1 { get { return targetable_vfo; } }
360 | public RigTransceive Transceive { get { return transceive; } }
361 | public int Bank_qty { get { return bank_qty; } }
362 | public int Chan_desc_sz { get { return chan_desc_sz; } }
363 | public IList Chan_list { get { return chan_list.CastList(); } }
364 | public FrequencyRange[] Rx_range_list1 { get { return rx_range_list1; } }
365 | public FrequencyRange[] Tx_range_list1 { get { return tx_range_list1; } }
366 | public FrequencyRange[] Rx_range_list2 { get { return rx_range_list2; } }
367 | public FrequencyRange[] Tx_range_list2 { get { return tx_range_list2; } }
368 | public IList Tuning_steps { get { return tuning_steps.CastList(); } }
369 | public IList Filters_list { get { return filters_list.CastList(); } }
370 | public CalibrationTable Str_cal { get { return str_cal; } }
371 | public IntPtr Cfgparams { get { return cfgparams; } }
372 | public IntPtr Priv { get { return priv; } }
373 | public IntPtr Rig_init { get { return rig_init; } }
374 | public IntPtr Rig_cleanup { get { return rig_cleanup; } }
375 | public IntPtr Rig_open { get { return rig_open; } }
376 | public IntPtr Rig_close { get { return rig_close; } }
377 | public IntPtr Set_freq { get { return set_freq; } }
378 | public IntPtr Get_freq { get { return get_freq; } }
379 | public IntPtr Set_mode { get { return set_mode; } }
380 | public IntPtr Get_mode { get { return get_mode; } }
381 | public IntPtr Set_vfo { get { return set_vfo; } }
382 | public IntPtr Get_vfo { get { return get_vfo; } }
383 | public IntPtr Set_ptt { get { return set_ptt; } }
384 | public IntPtr Get_ptt { get { return get_ptt; } }
385 | public IntPtr Get_dcd { get { return get_dcd; } }
386 | public IntPtr Set_rptr_shift { get { return set_rptr_shift; } }
387 | public IntPtr Get_rptr_shift { get { return get_rptr_shift; } }
388 | public IntPtr Set_rptr_offs { get { return set_rptr_offs; } }
389 | public IntPtr Get_rptr_offs { get { return get_rptr_offs; } }
390 | public IntPtr Set_split_freq { get { return set_split_freq; } }
391 | public IntPtr Get_split_freq { get { return get_split_freq; } }
392 | public IntPtr Set_split_mode { get { return set_split_mode; } }
393 | public IntPtr Get_split_mode { get { return get_split_mode; } }
394 | public IntPtr Set_split_freq_mode { get { return IntPtr.Zero; } } //set_split_freq_mode; } }
395 | public IntPtr Get_split_freq_mode { get { return IntPtr.Zero; } } //get_split_freq_mode; } }
396 | public IntPtr Set_split_vfo { get { return set_split_vfo; } }
397 | public IntPtr Get_split_vfo { get { return get_split_vfo; } }
398 | public IntPtr Set_rit { get { return set_rit; } }
399 | public IntPtr Get_rit { get { return get_rit; } }
400 | public IntPtr Set_xit { get { return set_xit; } }
401 | public IntPtr Get_xit { get { return get_xit; } }
402 | public IntPtr Set_ts { get { return set_ts; } }
403 | public IntPtr Get_ts { get { return get_ts; } }
404 | public IntPtr Set_dcs_code { get { return set_dcs_code; } }
405 | public IntPtr Get_dcs_code { get { return get_dcs_code; } }
406 | public IntPtr Set_tone { get { return set_tone; } }
407 | public IntPtr Get_tone { get { return get_tone; } }
408 | public IntPtr Set_ctcss_tone { get { return set_ctcss_tone; } }
409 | public IntPtr Get_ctcss_tone { get { return get_ctcss_tone; } }
410 | public IntPtr Set_dcs_sql { get { return set_dcs_sql; } }
411 | public IntPtr Get_dcs_sql { get { return get_dcs_sql; } }
412 | public IntPtr Set_tone_sql { get { return set_tone_sql; } }
413 | public IntPtr Get_tone_sql { get { return get_tone_sql; } }
414 | public IntPtr Set_ctcss_sql { get { return set_ctcss_sql; } }
415 | public IntPtr Get_ctcss_sql { get { return get_ctcss_sql; } }
416 | public IntPtr Power2mW { get { return power2mW; } }
417 | public IntPtr MW2power { get { return mW2power; } }
418 | public IntPtr Set_powerstat { get { return set_powerstat; } }
419 | public IntPtr Get_powerstat { get { return get_powerstat; } }
420 | public IntPtr Reset { get { return reset; } }
421 | public IntPtr Set_ant { get { return set_ant; } }
422 | public IntPtr Get_ant { get { return get_ant; } }
423 | public IntPtr Set_level { get { return set_level; } }
424 | public IntPtr Get_level { get { return get_level; } }
425 | public IntPtr Set_func { get { return set_func; } }
426 | public IntPtr Get_func { get { return get_func; } }
427 | public IntPtr Set_parm { get { return set_parm; } }
428 | public IntPtr Get_parm { get { return get_parm; } }
429 | public IntPtr Set_ext_level { get { return set_ext_level; } }
430 | public IntPtr Get_ext_level { get { return get_ext_level; } }
431 | public IntPtr Set_ext_parm { get { return set_ext_parm; } }
432 | public IntPtr Get_ext_parm { get { return get_ext_parm; } }
433 | public IntPtr Set_conf { get { return set_conf; } }
434 | public IntPtr Get_conf { get { return get_conf; } }
435 | public IntPtr Send_dtmf { get { return send_dtmf; } }
436 | public IntPtr Recv_dtmf { get { return recv_dtmf; } }
437 | public IntPtr Send_morse { get { return send_morse; } }
438 | public IntPtr Set_bank { get { return set_bank; } }
439 | public IntPtr Set_mem { get { return set_mem; } }
440 | public IntPtr Get_mem { get { return get_mem; } }
441 | public IntPtr Vfo_op { get { return vfo_op; } }
442 | public IntPtr Scan { get { return scan; } }
443 | public IntPtr Set_trn { get { return set_trn; } }
444 | public IntPtr Get_trn { get { return get_trn; } }
445 | public IntPtr Decode_event { get { return decode_event; } }
446 | public IntPtr Set_channel { get { return set_channel; } }
447 | public IntPtr Get_channel { get { return get_channel; } }
448 | public IntPtr Get_info { get { return get_info; } }
449 | public IntPtr Set_chan_all_cb { get { return set_chan_all_cb; } }
450 | public IntPtr Get_chan_all_cb { get { return get_chan_all_cb; } }
451 | public IntPtr Set_mem_all_cb { get { return set_mem_all_cb; } }
452 | public IntPtr Get_mem_all_cb { get { return get_mem_all_cb; } }
453 | public IntPtr Clone_combo_set { get { return clone_combo_set; } }
454 | public IntPtr Clone_combo_get { get { return clone_combo_get; } }
455 | }
456 | }
457 |
--------------------------------------------------------------------------------