private bool sendCommand(byte[] command, BurstModulationType modulationType) { IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024); for (int index = 0; index < commandBufferLength; ++index) { Marshal.WriteByte(commandBuffer, index, 0x00); } for (int index = 0; index < command.Length; ++index) { Marshal.WriteByte(commandBuffer, index, command[index]); } Marshal.WriteInt32(commandBuffer, 160, command.Length); //send message length Marshal.WriteInt32(commandBuffer, 164, 0); //receive message length Marshal.WriteInt32(commandBuffer, 168, 3); //amplitude attenuation Marshal.WriteInt32(commandBuffer, 172, (byte)modulationType); Marshal.WriteInt32(commandBuffer, 176, (int)DisEqcVersion.DISEQC_VER_1X); Marshal.WriteInt32(commandBuffer, 180, (int)RxMode.RXMODE_NOREPLY); Marshal.WriteInt32(commandBuffer, 184, 1); //last_message StringBuilder commandString = new StringBuilder("Conexant DiSEqC handler: sending command "); byte[] commandBytes = new byte[4]; for (int index = 0; index < 4; ++index) { commandBytes[index] = Marshal.ReadByte(commandBuffer, index); } commandString.Append(ConvertToHex(commandBytes)); for (int index = 160; index < commandBufferLength; index = (index + 4)) { commandString.Append(" " + Marshal.ReadInt32(commandBuffer, index)); } Logger.Instance.Write(commandString.ToString()); reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, commandBuffer, commandBufferLength, commandBuffer, commandBufferLength); if (reply != 0) { Logger.Instance.Write("Conexant DiSEqC handler: command failed error code 0x" + reply.ToString("X")); } else { Logger.Instance.Write("Conexant DiSEqC handler: command succeeded"); } return(reply == 0); }
private bool sendCommand(byte[] command, BurstModulationType modulationType, byte toneDataBurst) { IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024); for (int index = 0; index < commandBufferLength; ++index) Marshal.WriteByte(commandBuffer, index, 0x00); for (int index = 0; index < command.Length; ++index) Marshal.WriteByte(commandBuffer, index, command[index]); if (useGet) { Marshal.WriteByte(commandBuffer, 151, (byte)command.Length); //send message length Marshal.WriteByte(commandBuffer, 161, 0); //receive message length Marshal.WriteInt32(commandBuffer, 162, (int)modulationType); //phantom LNB burst - simple A/AA = unmodulated else modulated Marshal.WriteInt32(commandBuffer, 166, 2); //phantom no reply Marshal.WriteInt32(commandBuffer, 170, 3); //command mode Marshal.WriteByte(commandBuffer, 174, 0); //22hz off Marshal.WriteByte(commandBuffer, 175, toneDataBurst); //tone/data Marshal.WriteByte(commandBuffer, 176, 0); //parity errors Marshal.WriteByte(commandBuffer, 177, 0); //reply errors Marshal.WriteInt32(commandBuffer, 178, 1); //last message Marshal.WriteInt32(commandBuffer, 182, 0); //lnb power } else Marshal.WriteByte(commandBuffer, 10, (byte)command.Length); //send message length StringBuilder commandString = new StringBuilder("ProfRed/TBS DiSEqC handler: sending command "); byte[] commandBytes = new byte[4]; for (int index = 0; index < command.Length; ++index) commandBytes[index] = Marshal.ReadByte(commandBuffer, index); commandString.Append(ConvertToHex(commandBytes)); for (int index = 151; index < commandBufferLength; index++) commandString.Append(" " + Marshal.ReadByte(commandBuffer, index).ToString("X")); Logger.Instance.Write(commandString.ToString()); string getSetString; if (useGet) { int bytesReturned; reply = propertySet.Get(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, commandBuffer, 188, commandBuffer, 188, out bytesReturned); getSetString = "Get"; } else { reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, commandBuffer, 11, commandBuffer, 11); getSetString = "Set"; } if (reply != 0) Logger.Instance.Write("ProfRed/TBS DiSEqC handler: " + getSetString + " command failed error code 0x" + reply.ToString("X")); else Logger.Instance.Write("ProfRed/TBS DiSEqC handler: " + getSetString + " command succeeded"); return (reply == 0); }
private bool sendCommand(byte[] command, BurstModulationType modulationType, byte toneDataBurst) { IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024); for (int index = 0; index < commandBufferLength; ++index) { Marshal.WriteByte(commandBuffer, index, 0x00); } for (int index = 0; index < command.Length; ++index) { Marshal.WriteByte(commandBuffer, index, command[index]); } if (useGet) { Marshal.WriteByte(commandBuffer, 151, (byte)command.Length); //send message length Marshal.WriteByte(commandBuffer, 161, 0); //receive message length Marshal.WriteInt32(commandBuffer, 162, (int)modulationType); //phantom LNB burst - simple A/AA = unmodulated else modulated Marshal.WriteInt32(commandBuffer, 166, 2); //phantom no reply Marshal.WriteInt32(commandBuffer, 170, 3); //command mode Marshal.WriteByte(commandBuffer, 174, 0); //22hz off Marshal.WriteByte(commandBuffer, 175, toneDataBurst); //tone/data Marshal.WriteByte(commandBuffer, 176, 0); //parity errors Marshal.WriteByte(commandBuffer, 177, 0); //reply errors Marshal.WriteInt32(commandBuffer, 178, 1); //last message Marshal.WriteInt32(commandBuffer, 182, 0); //lnb power } else { Marshal.WriteByte(commandBuffer, 10, (byte)command.Length); //send message length } StringBuilder commandString = new StringBuilder("ProfRed/TBS DiSEqC handler: sending command "); byte[] commandBytes = new byte[4]; for (int index = 0; index < command.Length; ++index) { commandBytes[index] = Marshal.ReadByte(commandBuffer, index); } commandString.Append(ConvertToHex(commandBytes)); for (int index = 151; index < commandBufferLength; index++) { commandString.Append(" " + Marshal.ReadByte(commandBuffer, index).ToString("X")); } Logger.Instance.Write(commandString.ToString()); string getSetString; if (useGet) { int bytesReturned; reply = propertySet.Get(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, commandBuffer, 188, commandBuffer, 188, out bytesReturned); getSetString = "Get"; } else { reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, commandBuffer, 11, commandBuffer, 11); getSetString = "Set"; } if (reply != 0) { Logger.Instance.Write("ProfRed/TBS DiSEqC handler: " + getSetString + " command failed error code 0x" + reply.ToString("X")); } else { Logger.Instance.Write("ProfRed/TBS DiSEqC handler: " + getSetString + " command succeeded"); } return(reply == 0); }
private bool sendCommand(byte[] command, BurstModulationType modulationType) { IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024); for (int index = 0; index < commandBufferLength; ++index) Marshal.WriteByte(commandBuffer, index, 0x00); for (int index = 0; index < command.Length; ++index) Marshal.WriteByte(commandBuffer, index, command[index]); Marshal.WriteInt32(commandBuffer, 160, command.Length); //send message length Marshal.WriteInt32(commandBuffer, 164, 0); //receive message length Marshal.WriteInt32(commandBuffer, 168, 3); //amplitude attenuation Marshal.WriteInt32(commandBuffer, 172, (byte)modulationType); Marshal.WriteInt32(commandBuffer, 176, (int)DisEqcVersion.DISEQC_VER_1X); Marshal.WriteInt32(commandBuffer, 180, (int)RxMode.RXMODE_NOREPLY); Marshal.WriteInt32(commandBuffer, 184, 1); //last_message StringBuilder commandString = new StringBuilder("Hauppauge DiSEqC handler: sending command "); byte[] commandBytes = new byte[4]; for (int index = 0; index < 4; ++index) commandBytes[index] = Marshal.ReadByte(commandBuffer, index); commandString.Append(ConvertToHex(commandBytes)); for (int index = 160; index < commandBufferLength; index = (index + 4)) commandString.Append(" " + Marshal.ReadInt32(commandBuffer, index)); Logger.Instance.Write(commandString.ToString()); reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, commandBuffer, commandBufferLength, commandBuffer, commandBufferLength); if (reply != 0) Logger.Instance.Write("Hauppauge DiSEqC handler: command failed error code 0x" + reply.ToString("X")); else Logger.Instance.Write("Hauppauge DiSEqC handler: command succeeded"); return (reply == 0); }