Which plugin to use - Monueal 320

If you have a question or need help, this is the place to be.
Post Reply
Skaboy607
Posts: 3
Joined: Sat Aug 25, 2018 6:12 pm

Which plugin to use - Monueal 320

Post by Skaboy607 » Sat Aug 25, 2018 6:33 pm

Hi,

Hoping someone can me out. New to using Event Ghost, I have just a Logitech Harmony Elite which I can use to control Kodi when HTPC is on using a Bluetooth adaptor I purchased however I can't turn it on or off using Bluetooth, apparently this has to be over IR.

My case is a Monueal moncaso 320 which has a built in IR receiver and the remote that came with it will shut HTPC down and start it up so I guess I know the IR is working. Pretty sure it is a usb to com IR receiver.

No plugin i try loading with event ghost will register any key presses from it, most of the plugins fail to load. What am I doing wrong?

I am using event ghost 0.4.1 r1509 on win7 64bit.

Thank you

User avatar
kgschlosser
Site Admin
Posts: 4250
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Which plugin to use - Monueal 320

Post by kgschlosser » Sun Aug 26, 2018 3:36 am

OK so here is the deal. chances are the IR receiver uses the Microsoft ehome drivers.

so this is what you are going to need to do.

start eg as an Administrator.

right click the EG Icon and click on RunAs Administrator. This step is crucial your user account having Administrative privlages is not going to be good enough. EG specifically needs to be run using the Administrator account.

Once you have EG started. Add the MCE Remote Vista+ plugin.
In the configuration dialog for the plugin there is going to be a button for installing the alternate MCE IR service. go ahead and click this button.
Once it has installed you will close EG and reboot windows.

Once windows has rebooted open EG (not as Administrator) and ass the MCE Remote Vista+ plugin if it is not in your tree already.
Point any IR remote at your HTPC and press a button. You should see an event generated in EventGhost.

If you want to have friendly names for your remote presses you will need to program your remote to emulate a Windows Media Center remote. then you will get named events for the buttons.

If your remote can be set to emulate a Playstation BlueTeeth remote and you want EG to handle all of your remote control functions you can install the Playstation BlueTeeth remote plugin. along with the Kodi plugin. You will get events in EG for the remote keypresses that are sent using BlueTeeth Creat a macro for each of the Kido actions that you want to use via the remote control. drag and drop the events for the remote button presses into those macros.. and that's all there is to it.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4250
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Which plugin to use - Monueal 320

Post by kgschlosser » Sun Aug 26, 2018 3:37 am

I would also recommend using EventGhost 0.5 RC4 as it has a newer version of the MCE Remote Vista+ plugin in it. and the newer version has several bug fixes.
If you like the work I have been doing then feel free to Image

Skaboy607
Posts: 3
Joined: Sat Aug 25, 2018 6:12 pm

Re: Which plugin to use - Monueal 320

Post by Skaboy607 » Sun Aug 26, 2018 11:55 am

Hi,

Thanks for your help so far.

I have uninstalled my previous version of EG and downloaded the 0.5 RC4 version.

Then I added the McE remote having opened up as admin.

Restarted windows and opened EG, plugin was already loaded.

Pointed both the Logitech harmony elite remote and the case remote but nothing was recognised.

Should I be using a different plugin?

User avatar
kgschlosser
Site Admin
Posts: 4250
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Which plugin to use - Monueal 320

Post by kgschlosser » Sun Aug 26, 2018 2:54 pm

OK this is all going to depend on your logitech remote. it does have the ability to send IR yes???

I would image it has the ability to both send IR and BT
you will need to put it into a mode to send an IR code.

Most Harmony remotes are Activity based remotes. and when you program the things you have to set up the activities and devices. you will need to either create a new device and add the remote codes for a Windows Media Center device. or you should be able to select a device that you already have made that uses IR

or you can go into that junk drawer. the one where you have remotes to random items you no longer own. LOL. get some good batteries into it. and point that at the HTPC and fire away. The receiver should pick up any IR that is considered an CIR protocol.


check in your device manager as well and see if there is a device in there called Microsoft ehome Transceiver or some kind of an entry for a CIR device. Something along those lines.


Also you made sure that you installed the MCE Remote Vista+ there are 2 MCE Remote plugins. Microsoft made 2 versions of the MCE Remote protocol. one for Windows XP Media Center. and one for the newer version of Media Center. so we want to make sure we are using the correct one.

Also if you go into Control Panel ----> Administrative Tools ----> Services. In the right panel locate the "AlternateMCEIr" service. and verify that it is in fact running.

if it is not you will need to start EG as an Administrator. go into the plugin config for the MCE Remote Vista+ plugin and click on the button to Start the service. or to install it if it is not in the services list. if you have to install it. then you will need to reboot your PC afterwards.
If you like the work I have been doing then feel free to Image

Skaboy607
Posts: 3
Joined: Sat Aug 25, 2018 6:12 pm

Re: Which plugin to use - Monueal 320

Post by Skaboy607 » Sun Aug 26, 2018 4:31 pm

Hi,

I’ve tried a number of differen remotes and not one of them registers any IR activity. However I know the IR works because with the cases remote I can shut the system down and start back up again.

Do you think it is down to an incorrect driver or plugin?

See link below for a review of my case, it talks about the ir and display there. I can’t see an ehome device in Dev manager, only the usb to com (com3) that it talks about in the review. If I remember correctly I installed and download (long time ago now) FTID drivers for this and indeed they still show up when I click on proprieties of the usb to com device.

User avatar
kgschlosser
Site Admin
Posts: 4250
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Which plugin to use - Monueal 320

Post by kgschlosser » Sun Aug 26, 2018 6:57 pm

Ok cool. Let me pull up the specs on the case and see where I get with that.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4250
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Which plugin to use - Monueal 320

Post by kgschlosser » Sun Aug 26, 2018 7:19 pm

Ok so this is what I have found. And this is what I can do.


I have located the source code of the drivers for the VL Systems LCD and IR receiver on the front of the case..

Yay

Code: Select all

#endregion

using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;
using System.Threading;
using System.Diagnostics;
using LcdWriter.SDK;
using LcdWriter.Shared;
using LcdWriter.Shared.SDK;
using System.Text.RegularExpressions;
using System.IO;

namespace LcdWriter.COMPort
{
    public class M320BDisplay : IDisposable, ILcdWriter, IRemoteControl, IDetectDisplay
    {
        private bool _disposed = false;
        private int totalRepeat;
        private int currrentRepeat;
        int columns;
        int rows;
        LCD_Line[] Lines;
        private SerialPort port = null;
        object objLock = new object();
        object renderLock = new object();
        object readLock = new object();
        TopLineStatus currentIcon = TopLineStatus.None;
        int writeRow = 1;
        string lastRender = string.Empty;
        byte commandBuffer = 0;
        bool isRepeat = false;
        bool remoteOnly = false;
        AutoResetEvent _reDetect = null;
        bool _foundPort = false;

        struct Commands
        {
            public static byte Exec = 0x01; 
            public static byte EOL = 0x09;
            public static byte Ping = 0x90;
            public static byte Find = 0x96;
            public static byte Command = 0x97;
            public static byte RemoteCommand = 0x7E;
            public static byte[] WriteData = { 0x93, Exec };
            //public static byte[] RedLightOn = { 0x9, Exec };
            //public static byte[] RedLightOff = { 0x9B, 0x02 };
            public static byte[] Success = { 0xFB, 0x82 };
        }

        enum TopLineStatus : byte
        {
            None = 0,
            DVD = 0x1,
            Movie,
            Music,
            TV,
            Photo,
            Radio,
            Play,
            Pause,
            Stop,
            Record,
            Res480,
            Res720,
            Res1080,
            MobileSync
        }

        public M320BDisplay()
        {
            columns = 14;
            rows = 2;
            Lines = new LCD_Line[rows];
            int x;
            for (x = 0; x < rows; x++)
                Lines[x] = new LCD_Line();
        }

        private void Write(byte data)
        {
            byte[] buffer = new byte[] { data };
            Write(buffer);
        }

        private void Write(byte[] buffer)
        {
            if (port != null && port.IsOpen)
            {
                lock (objLock)
                    port.Write(buffer, 0, buffer.Length);
            }
        }

        private void Write(string data)
        {
            if (remoteOnly)
                return;

            Write(Commands.WriteData);
            if (port != null && port.IsOpen)
            {
                lock (objLock)
                    port.Write(data);
            }
            Write(Commands.EOL);
        }

        private byte[] Read()
        {
            byte[] buffer = new byte[512];
            int readSize = 0;
                
            if (port != null && port.IsOpen)
            {
                lock (objLock)
                {
                    readSize = port.Read(buffer, 0, 512);
                }
            }

            byte[] retBuffer = new byte[readSize];
            for (int i = 0; i < readSize; i++)
                retBuffer[i] = buffer[i];

            return retBuffer;
        }

        private void ToggleIcon(TopLineStatus Position, bool On)
        {
            lock (objLock)
            {
                if(On)
                    port.Write(new byte[] { Commands.Command, (byte)Position, 0x02 }, 0, 3);
                else
                    port.Write(new byte[] { Commands.Command, (byte)Position, Commands.Exec }, 0, 3);
            }
        }

        private void WriteIcon(IconType icon)
        {
            TopLineStatus req = TopLineStatus.None;

            switch (icon)
            {
                case IconType.Stop:
                    req = TopLineStatus.Stop;
                    break;
                case IconType.Record:
                    req = TopLineStatus.Record;
                    break;
                case IconType.Pause:
                    req = TopLineStatus.Pause;
                    break;
                case IconType.Play:
                    req = TopLineStatus.Play;
                    break;
            }

            if (currentIcon != req)
                ClearIconState();

            ToggleIcon(req, true);

            //if (req == TopLineStatus.Record)
            //    Write(Commands.RedLightOn);

            currentIcon = req;
        }

        private void ClearIconState()
        {
            FileLogger.Log("ClearIconState");
            if (remoteOnly)
                return;

            lock (objLock)
            {
                for (int i = 1; i < 15; i++)
                    port.Write(new byte[] { Commands.Command, (byte)i, Commands.Exec }, 0, 3);
            }
            //Write(Commands.RedLightOff);
        }

        private string CleanDate(string buffer)
        {
            string tmpBuffer = Regex.Replace(buffer, "^(\\d{1,2}:\\d\\d \\w\\w) (\\d{1,2}/\\d{1,2})/?\\d*", "$2 $1", RegexOptions.Compiled);
            int freeSpace = columns - tmpBuffer.Length;
            if (freeSpace > 1)
            {
                int pad = freeSpace / 2;

                StringBuilder sbBuffer = new StringBuilder(columns);
                for (int i = 0; i < pad; i++)
                    sbBuffer.Append(" ");
                sbBuffer.Append(tmpBuffer);
                tmpBuffer = sbBuffer.ToString();
            }
            return tmpBuffer.PadRight(columns, ' ');
        }

        void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            if (e.EventType == SerialData.Chars)
            {
                FileLogger.Log("DataReceived");
            
                lock (readLock)
                {
                    byte[] buffer = new byte[port.ReadBufferSize];
                    int received = port.Read(buffer, 0, port.ReadBufferSize);

                    string txtData = Encoding.ASCII.GetString(buffer, 0, received);
                    if (received > 0 && received < 4)
                    {
                        try
                        {                           
                            for (int i = 0; i < received; i++)
                            {
                                Debug.Print("{0:x}", buffer[i]);
                                if (buffer[i] != Commands.RemoteCommand)
                                {
                                    commandBuffer = buffer[i];
                                    isRepeat = false;
                                }
                                else
                                {
                                    if(OnKey != null)
                                            OnKey(null, new RemoteKeyEvent((RemoteKeys)commandBuffer, isRepeat));
                                    isRepeat = true;
                                }
                            }
                        }
                        catch (Exception ex) { }
                    }
                    else if (received > 4 && txtData.IndexOf(".M") == 0)
                    {
                        _foundPort = true;
                        if (_reDetect != null)
                            _reDetect.Set();
                    }
                }
            }
        }

        #region ILcdWriter Members

        public void Clear()
        {
            FileLogger.Log("Clear");
            ClearIconState();
            Write("              ");
        }

        public void Standby()
        {
            FileLogger.Log("Standby");
            this.Clear();
            BaseSettings bs = new BaseSettings();
            if (bs.CleanupOnStandby)
            {
                try
                {
                    lock (objLock)
                    {
                        try
                        {
                            if (port.IsOpen)
                            {
                                port.DiscardInBuffer();
                                port.DiscardOutBuffer();
                                port.BaseStream.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.Print(ex.ToString());
                        }
                        port.Dispose();
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    port = null;
                }
            }
        }

        public void Init()
        {
            FileLogger.Log("Init: {0}", port == null);
            BaseSettings bs = new BaseSettings();
            remoteOnly = bs.RemoteOnly;
            if (bs.CleanupOnStandby)
            {
                if (port != null)
                {
                    lock (objLock)
                        port.Dispose();
                    port = null;
                }
            }

            Thread.Sleep(100);
            if (port == null)
            {
                FileLogger.Log("Init: pre lock");
                lock (objLock)
                {
                    FileLogger.Log("Init: post lock");
                    try
                    {
                        port = new SerialPort(bs.PortName, 57600, Parity.None, 8, StopBits.One);
                        port.Encoding = Encoding.ASCII;
                        port.WriteBufferSize = 2048;
                        port.ReadBufferSize = 2048;
                        port.ReadTimeout = 1000;
                        port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
                        port.Open();
                        FileLogger.Log("Init: open");                
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        Thread.Sleep(100);
                    }
                }
            }
            Write(Commands.Find);
            Clear();
            Thread.Sleep(100);
        }

        public void Render()
        {
            if (remoteOnly)
                return;

            string text1 = new string('c', columns);
            for (byte num1 = 0; num1 < rows; num1 = (byte)(num1 + 1))
            {
                if (this.Lines[num1].lrt == 0)
                {
                    this.Lines[num1].lrt = (DateTime.Now.Ticks / ((long)10000)) - this.Lines[num1].freq;
                }
                else if (((DateTime.Now.Ticks / ((long)10000)) - this.Lines[num1].lrt) >= this.Lines[num1].freq)
                {
                    if ((this.Lines[num1].line.Length - this.Lines[num1].pos) <= columns)
                    {
                        if (this.currrentRepeat >= this.totalRepeat)
                        {
                            this.Lines[num1].scrollable = false;
                        }
                        this.Lines[num1].pos = 0;
                        this.currrentRepeat++;
                    }
                    if (this.Lines[num1].line.Length > columns)
                    {
                        int pad = 0;
                        if(Regex.IsMatch(this.Lines[num1].line, "^[>|<|@|{|}|$|\\||+]"))
                            pad = 2;

                        text1 = this.Lines[num1].line.Substring(this.Lines[num1].pos, this.columns+pad);
                    }
                    else
                    {
                        text1 = this.Lines[num1].line.Substring(this.Lines[num1].pos, this.Lines[num1].line.Length);
                        text1 = text1.PadRight(columns);
                    }
                    if (this.Lines[num1].scrollable)
                    {
                        LCD_Line line1 = this.Lines[num1];
                        line1.pos++;
                    }
                    this.RenderString(num1, text1);
                    this.Lines[num1].lrt = DateTime.Now.Ticks / ((long)10000);
                }
            }
        }

        public void RenderString(byte row, string buffer)
        {

            if (remoteOnly)
                return;

            //int index = 0;
            //SetRow(row);
            lock (renderLock)
            {
                string writeString = string.Empty;
                string c = buffer[0].ToString();
                if (c == ">") // fast forward
                {
                    WriteIcon(IconType.FastForward);
                    writeRow = 1;
                }
                else if (c == "<") // rewind
                {
                    WriteIcon(IconType.Rewind);
                    writeRow = 1;
                }
                else if (c == "}") // skip forward
                {
                    WriteIcon(IconType.SkipForward);
                    writeRow = 1;
                }
                else if (c == "{") // skip backward
                {
                    WriteIcon(IconType.SkipBack);
                    writeRow = 1;
                }
                else if (c == "$") // play
                {
                    WriteIcon(IconType.Play);
                    writeRow = 1;
                }
                else if (c == "@") // record
                {
                    WriteIcon(IconType.Record);
                    writeRow = 0;
                }
                else if (c == "|") // pause
                {
                    WriteIcon(IconType.Pause);
                    writeRow = 1;
                }
                else if (c == "+") // stop
                {
                    WriteIcon(IconType.Stop); 
                    writeRow = 1;
                }
                else
                {
                    if (row == 1 && currentIcon != TopLineStatus.None)
                    {
                        writeRow = 1;
                        ClearIconState();
                        currentIcon = TopLineStatus.None;
                    }

                    if(writeRow == row){
                        writeString = CleanDate(buffer.Trim());
                        if (writeString != lastRender)
                            Write(writeString);
                        lastRender = writeString;
                    }
                    return;
                }

                if (buffer.Length > 1 && writeRow == row)
                {
                    writeString = CleanDate(buffer.Substring(1).Trim()); 
                    if (writeString != lastRender)
                        Write(writeString);
                    lastRender = writeString;
                }
            }
        }

        public void ReviseString(int index, string buffer)
        {
            if (remoteOnly)
                return;

            int num1 = this.Lines[index].line.Length;
            this.Lines[index].line = buffer.Substring(0, num1);
            if (this.Lines[index].scrollable)
            {
                string text1;
                LCD_Line line1 = this.Lines[index];
                line1.line = line1.line + this.Lines[index].sep;
                LCD_Line line2 = this.Lines[index];
                line2.line = text1 = line2.line + this.Lines[index].line.Substring(0, columns);
                this.Lines[index].line = text1;
            }
        }

        public void SetString(int index, string buffer, bool scroll, string sep, long rate, int repeat)
        {
            if (remoteOnly)
                return;

            this.Lines[index].line = buffer;
            this.Lines[index].sep = sep;
            this.Lines[index].scrollable = scroll;
            this.Lines[index].freq = rate;
            this.Lines[index].pos = 0;
            if (scroll)
            {
                string text1;
                LCD_Line line1 = this.Lines[index];
                line1.line = line1.line + this.Lines[index].sep;
                LCD_Line line2 = this.Lines[index];
                line2.line = text1 = line2.line + this.Lines[index].line.Substring(0, columns);
                this.Lines[index].line = text1;
                this.totalRepeat = repeat;
                this.currrentRepeat = 0;
            }
        }

        public void SetIcons(LcdIconCollection icons)
        {
            FileLogger.Log("SetIcons");
            if (remoteOnly)
                return;

            Clear();
        }

        public int GetColumns()
        {
            return columns;
        }

        public int GetRows()
        {
            return rows;
        }

        #endregion

        #region IDisposable Members

        protected void Dispose(bool disposing)
        {
            FileLogger.Log("Dispose Display: {0}", disposing);
            if (!_disposed)
            {
                if (disposing)
                {
                    if (port != null)
                    {
                        Clear();
                        {
                            //Write(Commands.Done);
                            lock (objLock)
                            {
                                try
                                {
                                    if (port.IsOpen)
                                    {
                                        port.DiscardInBuffer();
                                        port.DiscardOutBuffer();
                                        port.BaseStream.Dispose();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.ToString());
                                }
                                port.Dispose();
                            }
                            port = null;
                        }
                    }
                }
                _disposed = true;
            }
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        #endregion

        #region IRemoteControl Members

        public event EventHandler<RemoteKeyEvent> OnKey;

        #endregion

        #region IDetectDisplay Members

        public DisplayType GetDisplayType()
        {
            return DisplayType.COMPort;
        }

        public string DetectDisplay()
        {
            string retName = string.Empty;
            _reDetect = new AutoResetEvent(false);
            List<string> errors = new List<string>();

            try
            {
                foreach (string portName in SerialPort.GetPortNames())
                {
                    try
                    {
                        port = new SerialPort(portName, 57600, Parity.None, 8, StopBits.One);
                        port.Encoding = Encoding.ASCII;
                        port.WriteBufferSize = 2048;
                        port.ReadBufferSize = 2048;
                        port.ReadTimeout = 2000;
                        port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
                        port.Open();
                        Write(Commands.Find);
                        if (_reDetect.WaitOne(2000) && _foundPort)
                        {
                            retName = portName;
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        errors.Add(ex.Message);
                    }
                    finally
                    {
                        try
                        {
                            if (port.IsOpen)
                            {
                                port.DiscardInBuffer();
                                port.DiscardOutBuffer();
                                port.BaseStream.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                        }
                        port.Dispose();
                        port = null;
                    }
                }
            }
            finally
            {
                _reDetect.Close();
                _reDetect = null;
            }

            if (errors.Count > 0)
            {
                return errors[0];
            }
            else
                return retName;
        }

        #endregion
    }
}


This is a pretty straight forward driver. It simply passes information from the serial port to the WIndows API for the remote and from the Windows API to the serial port for the LCD.


Now this is what I will be able to do. Bit I am going to need something from you. I am going to need you to install a program called realterm and you will need to set up an echo server. What that is going to enable you to do it connect the serial port for the display and redirect it to a telnet port. You will need to forward the port in your router to your computer. This is so that I will be able to connect to the thing in order to make something for ya.

I am thinking you would find use of being able to display text and icons on the LCD screen. This is something I would be able to add.

What I do not know is if that IR receiver is keyed to only the remote that came with the case. This is why I need that connection. So I can have a look see at the data. You will need to make sure that any program that controls that display is not running if/when we do this.

But that is pretty much where I am at.

Let me know what you want to do.
If you like the work I have been doing then feel free to Image

Post Reply