ReadWritePhySettings Method - intrepidcs API¶
C/C++ declare - VB.NET declare - C# declare - Parameters - Return Values - Remarks - C/C++ example - VB.NET example - C# example
This method allows reading and writing the PHY settings from/to the hardware.
C/C++ Declare¶
int _stdcall icsneoReadWritePHYSettings(void * hObject, PhyRegPkt_T *PHYSettings, size_t Size, size_t NumEntries);
Visual Basic .NET Declare¶
Public Declare Function icsneoReadWritePHYSettings Lib “icsneo40.dll” (ByVal hObject As IntPtr, ByRef PHYSettings As PhyRegPkt_T, ByVal iSize As IntPtr, ByVal NumEntries As IntPtr) As Int32
C# Declare¶
[DllImport(“icsneo40.dll”)] public static extern Int32 icsneoReadWritePhySettings(IntPtr hObject, ref PhyRegPkt_T PHYSettings, IntPtr iSize, IntPtr NumEntries);
Parameters¶
- hObject
[in] Specifies the driver object created by OpenNeoDevice.
- PHYSettings
[out] This is the address of the first element of an array of PhyRegPkt_T structures. This array will be loaded by the application software with entries to be read or written from/to the hardware.
- iSize
[in] Specifies the size of the structure PhyRegPkt_T used by the application. This is to make sure the structure used in the application and the DLL is same to avoid any buffer overrun.
- iNumEntries
[in] Specifies the number of PHY Entries to be read or written.
Return Values¶
Returns 1 if successful, 0 if an error occurred. GetLastAPIError must be called to obtain the specific error.
Remarks¶
This function call sends the PHY Entries to be read or written from/to the hardware.
Examples¶
C/C++ Example¶
PhySettings.clause22.phyAddrOrPort = 0x6;
PhySettings.clause.regAddr = 0x2;
PhySettings.clause.pageOrDevice = 1;
PhySettings.WriteEnable = 0;
PhySettings.Enabled = 1; //if not enabled, this entry of read/write operation will be ignored even if it is passed in.
PhySettings.Clause45Enable = 0; //Set this to 1 if the application is sending Clause45 type of Entries.
icsneoReadWritePHYSettings(handle, &PhySettings, sizeof(PhyRegPkt_t), 1);
C# Example¶
Int32 iResult;
PhyRegPkt_t PhyRegPkt;
int iTempFlags = 0;
//Copy data to the structure
PhyRegPkt.ClausePkt.phyAddrOrPort = 6;
PhyRegPkt.ClausePkt.pageOrDevice = 1;
PhyRegPkt.ClausePkt.regAddr = 2;
PhyRegPkt.ClausePkt.regVal = 0;
//Set for Reading using Clause45 and Enabled
iTempFlags = iTempFlags | (int)PhyRegFlags.Enabled;
iTempFlags = iTempFlags | (int)PhyRegFlags.Clause45Enable;
PhyRegPkt.Flags = (ushort)iTempFlags;
//Get and cast the size of the structrue.
iResult = icsNeoDll.icsneoReadWritePHYSettings(m_hObject, ref PhyRegPkt, (IntPtr)System.Runtime.InteropServices.Marshal.SizeOf(PhyRegPkt), (IntPtr)1);
System.Diagnostics.Debug.WriteLine(Convert.ToString(PhyRegPkt.ClausePkt.regVal));
Visual Basic .NET Example¶
Dim iResult As Int32
Dim PhyRegPkt As PhyRegPkt_t
Dim iTempFlags As Int32 = 0
Dim iParamCount As IntPtr = CType(1, IntPtr)
'//Copy data to the structure
PhyRegPkt.ClausePkt.phyAddrOrPort = 6
PhyRegPkt.ClausePkt.pageOrDevice = 1
PhyRegPkt.ClausePkt.regAddr = 3
PhyRegPkt.ClausePkt.regVal = 0
'//Set for Reading using Clause45 and Enabled
iTempFlags = iTempFlags Or PhyRegFlags.Enabled
iTempFlags = iTempFlags Or PhyRegFlags.Clause45Enable
PhyRegPkt.Flags = CUShort(iTempFlags)
'//Get and cast the size of the structrue.
Dim PhyRegSize As IntPtr = CType(System.Runtime.InteropServices.Marshal.SizeOf(PhyRegPkt), IntPtr)
iResult = icsneoReadWritePHYSettings(m_hObject, PhyRegPkt, PhyRegSize, iParamCount)
Debug.Print(CStr(PhyRegPkt.ClausePkt.regVal))