コード例 #1
0
        internal RigCaps(IRigCapsNative rigCapsNative, Rig rig = null)
        {
            this.rigCapsNative = rigCapsNative;

            if (rig != null)
            {
                if (rigCapsNative.Extparms != IntPtr.Zero)
                {
                    extparms = rig.GetExtParm(rigCapsNative.Extparms);                      //DecodeExtParms (rig, rigCapsNative.Extparms);
                }

                if (rigCapsNative.Extlevels != IntPtr.Zero)
                {
                    extlevels = rig.GetExtLevels(rigCapsNative.Extlevels);                      //DecodeExtLevels (rig, rigCapsNative.Extlevels);
                }
            }

            if (rigCapsNative.Ctcss_list != IntPtr.Zero)
            {
                ctcss_list = DecodeList(rigCapsNative.Ctcss_list);
            }

            if (rigCapsNative.Dcs_list != IntPtr.Zero)
            {
                dcs_list = DecodeList(rigCapsNative.Dcs_list);
            }

            channelList = CreateChannelList(rigCapsNative.Chan_list);
            tuningStep  = CreateModeValueList(rigCapsNative.Tuning_steps);
            filterList  = CreateModeValueList(rigCapsNative.Filters_list);
        }
コード例 #2
0
ファイル: HamLib.cs プロジェクト: mrbubble62/HamLibSharp
        internal static IRigCapsNative MarshalRigCaps(IntPtr rig_caps)
        {
            IRigCapsNative caps = null;

            switch (hamLibVersion)
            {
            case HamLibVersion.Current:
                // if the platform is 64-bit, but not windows
                if (!isWindows && bitsize64)
                {
                    caps = Marshal.PtrToStructure <RigCapsNative64> (rig_caps);
                }
                else
                {
                    caps = Marshal.PtrToStructure <RigCapsNative32> (rig_caps);
                }
                break;

            case HamLibVersion.V301:
                if (!isWindows && bitsize64)
                {
                    caps = Marshal.PtrToStructure <RigCapsNative64v301> (rig_caps);
                }
                else
                {
                    caps = Marshal.PtrToStructure <RigCapsNative32v301> (rig_caps);
                }
                break;

            case HamLibVersion.V2:
                if (!isWindows && bitsize64)
                {
                    caps = Marshal.PtrToStructure <RigCapsNative64v2> (rig_caps);
                }
                else
                {
                    caps = Marshal.PtrToStructure <RigCapsNative32v2> (rig_caps);
                }
                break;

            default:
                throw new RigException("Unknown or Incompatible HamLib library found");
            }

            return(caps);
        }
コード例 #3
0
ファイル: HamLib.cs プロジェクト: mrbubble62/HamLibSharp
        static HamLibVersion PreInitLibrary()
        {
            INativeRig     initRig  = null;
            IRigCapsNative initCaps = null;
            HamLibVersion  version;

            SetDebugLevel(RigDebugLevel.None);

            // test what version of hamlib is on our system use the Dummy Rig
            var theRig = Rig.rig_init(1);

            if (!isWindows && bitsize64)
            {
                initRig  = Marshal.PtrToStructure <NativeRig64> (theRig);
                initCaps = Marshal.PtrToStructure <RigCapsNative64> (initRig.Caps);
                if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero)
                {
                    version = HamLibVersion.Current;
                }
                else
                {
                    initCaps = Marshal.PtrToStructure <RigCapsNative64v301> (initRig.Caps);
                    if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero)
                    {
                        version = HamLibVersion.V301;
                    }
                    else
                    {
                        initCaps = Marshal.PtrToStructure <RigCapsNative64v2> (initRig.Caps);
                        if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero)
                        {
                            version = HamLibVersion.V2;
                        }
                        else
                        {
                            version = HamLibVersion.Unknown;
                        }
                    }
                }
            }
            else
            {
                initRig = Marshal.PtrToStructure <NativeRig32> (theRig);

                initCaps = Marshal.PtrToStructure <RigCapsNative32> (initRig.Caps);
                if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero)
                {
                    version = HamLibVersion.Current;
                }
                else
                {
                    initCaps = Marshal.PtrToStructure <RigCapsNative32v301> (initRig.Caps);
                    if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero)
                    {
                        version = HamLibVersion.V301;
                    }
                    else
                    {
                        initCaps = Marshal.PtrToStructure <RigCapsNative32v2> (initRig.Caps);
                        if (initCaps.Priv == IntPtr.Zero && initCaps.Decode_event == IntPtr.Zero)
                        {
                            version = HamLibVersion.V2;
                        }
                        else
                        {
                            version = HamLibVersion.Unknown;
                        }
                    }
                }
            }

            return(version);
        }