private bool sendCommand(byte[] command) { IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024); IntPtr replyBuffer = Marshal.AllocCoTaskMem(1024); for (int index = 0; index < command.Length; ++index) { Marshal.WriteByte(commandBuffer, index, command[index]); } DiseqcCommand diseqcCommand = new DiseqcCommand(); for (int index = 0; index < diseqcCommand.Command.Length; index++) { diseqcCommand.Command[index] = 0x00; } for (int index = 0; index < command.Length; ++index) { diseqcCommand.Command[index] = command[index]; } diseqcCommand.CommandLength = (byte)command.Length; Marshal.StructureToPtr(diseqcCommand, commandBuffer, false); int length = Marshal.SizeOf(diseqcCommand); Logger.Instance.Write("GenPix DiSEqC Handler: sending command " + ConvertToHex(diseqcCommand.Command)); reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, replyBuffer, 32, commandBuffer, length); if (reply != 0) { Logger.Instance.Write("GenPix DiSEqC handler: command failed error code 0x" + reply.ToString("X")); } else { Logger.Instance.Write("GenPix DiSEqC handler: command succeeded"); } return(reply == 0); }
private bool sendCommand(byte[] command) { IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024); IntPtr replyBuffer = Marshal.AllocCoTaskMem(1024); for (int index = 0; index < command.Length; ++index) Marshal.WriteByte(commandBuffer, index, command[index]); DiseqcCommand diseqcCommand = new DiseqcCommand(); for (int index = 0; index < diseqcCommand.Command.Length; index++) diseqcCommand.Command[index] = 0x00; for (int index = 0; index < command.Length; ++index) diseqcCommand.Command[index] = command[index]; diseqcCommand.CommandLength = (byte)command.Length; Marshal.StructureToPtr(diseqcCommand, commandBuffer, false); int length = Marshal.SizeOf(diseqcCommand); Logger.Instance.Write("GenPix DiSEqC Handler: sending command " + ConvertToHex(diseqcCommand.Command)); reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, replyBuffer, 32, commandBuffer, length); if (reply != 0) Logger.Instance.Write("GenPix DiSEqC handler: command failed error code 0x" + reply.ToString("X")); else Logger.Instance.Write("GenPix DiSEqC handler: command succeeded"); return (reply == 0); }