public void VirtualChannelWrite(byte[] data)
        {
            ChannelReturnCodes ret = _entryPoints.
                                     VirtualChannelWrite(_openChannel, data, (uint)data.Length, IntPtr.Zero);

            if (ret != ChannelReturnCodes.Ok)
            {
                throw new VirtualChannelException(String.Format("TsClientAddIn ({0}): Couldn't write to communcation channel for battery monitor.", _channelName));
            }
        }
Пример #2
0
        public bool WriteMessage(ChannelMessage msg)
        {
            var data = msg.ToByteArray();
            var len  = 4 + data.Length;
            var ptr  = Marshal.AllocHGlobal(len);

            Marshal.WriteInt32(ptr, 0, data.Length);
            Marshal.Copy(data, 0, new IntPtr(ptr.ToInt32() + 4), data.Length);
            var ret = entryPoints.VirtualChannelWrite(OpenChannel, ptr, (uint)len, ptr);

            return(ret == ChannelReturnCodes.Ok);
        }