Serial control of the Oppo BDP-103

If you have a question or need help, this is the place to be.
jachin99
Experienced User
Posts: 547
Joined: Sat Feb 13, 2016 8:39 pm

Serial control of the Oppo BDP-103

Post by jachin99 » Sun Aug 19, 2018 3:14 am

I picked up a Oppo bdp-103 bluray player, and I would like to try controlling it with EventGhost, which leaves me with the options of IR, IP control or RS-232. Of these three I think I prefer RS-232 because my IR gear isn't quite as good as I would prefer, and serial gives me an Always On connection directly between the two devices. I have nothing against web control but I can't seem to find a whole lot of documentation on exactly how to implement it. Eventghost does have a serial plugin however, and the commands seem simple enough to learn that I think I would like to give it a try. With a WHOLE LOT of luck, maybe I can get EG to control my mitsubishi TV over serial as well but thats not my immediate goal. Here is a link to the Oppo's documentation for serial control of the player: file:///C:/Users/Workstation/Downloads/BDP-103_RS232_Protocol_v1.1.pdf

My serial to USB dongle should come in the next day or two but until then all I can really do is read about it and ask questions. From looking over that document, and never having played with serial commands, I'm going to show you all what my best attempt at structuring a power on command, and maybe someone can tell me if I'm headed in the right direction. If only automation could have stayed this simple... Quoting from the pdf file, the commands are supposed to be structured as follows

Code: Select all

The illustration of the command structure is as the followings: 
<Command> = <Start of Command><Command Code>[<sp><Parameters>]  
<End of Command> 
<Start of Command> = #, ASCII 0x23 
<Command Code> = <byte><byte><byte> 
<sp> = space, ASCII 0x20 
<Parameters> = command-specific 
<End of Command> = CR, ASCII 0x0d 
So to me a power on command should look like this in ascii:
0x25 112 111 119 0x0d

I doubt that's totally correct and the first question that comes to my mind is when I send this sequence in eventghost do I structure it in a an XML like format as referenced in the documentation? IF I just create a string of ascii characters how do i separate those so that the player knows one command from the next? Thanks for the help.

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

Re: Serial control of the Oppo BDP-103

Post by kgschlosser » Sun Aug 19, 2018 6:18 am

OK this is where i hate to throw the wrench into your gears.

You stated that the player has RS232 control. this is not going to work with a USB to serial adapter.

serial is not necessarily RS-232.

RS-232 is a connection type that uses serial data communications. RS-232 is a +- 12V communications.
A usb to serial adapter is a TTL connection type. what this means.. a USB port only has +- 5 volts available to it. you cannot make 12 volts from the 5 volts. and 5 volts is below the threshold that RS-232 is capable of reading. PLUS if your RS-232 transmits to a connected TTV serial device it is going to cook it. because the TTL serial has a max input of +5v now there is a little wiggle room with that number but not up to 12v. now you can create a voltage divider using a couple of resistors that will bring that 12v down to a safe level that the TTL serial device would be OK with. but that still does not solve the issue of bumping the 6 volt output of the TTL device to a level that the RS-232 can read. so at best you can receive from the player but not send to it.

Now as far as the Mitsubishi TV is concerned if it to has an RS-232 connection it is going to be the same deal. i think that Mitsubishi TV's if you send the IR codes into the serial it will work. on some TV's they have an EX-Link port (Samsung) or something equivalent. which would be in the form of a headphone jack. I am almost certain you can buy a male to male mono headphone cord and plug directly from a blaster right into that port and it will work.

If the RS232 connection on either the TV or the player is in the form of a DB-9 connector. (old school serial mouse) it is going to be RS-232 +-12V if it is in the form of a headphone jack. then it is a crap shoot and either locate the specifications for the port or you are going to have to take a volt ohm meter and check the voltage on the RX and TX lines when doing something on the device.

Now as far as the ports are concerned. you may need to locate how to get into the hotel menu or the hidden system settings menu. sometimes the ports are disabled and need to be enabled via this menu.

I would suggest IP control because of the complexities with the serial on a device. so long as there are no limitations imposed by the IP control (as with Samsung and not being able to turn the device on).

let me see if i can dig up some information on both the specifications for the player and the TV as well.

I will need the model number of the TV


also i do not think this link is going to work
file:///C:/Users/Workstation/Downloads/BDP-103_RS232_Protocol_v1.1.pdf
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: Serial control of the Oppo BDP-103

Post by kgschlosser » Sun Aug 19, 2018 6:22 am

The BDP-103/105 Blu-ray Disc Player comes standard with an RS-232 port for wired remote control. The RS-232C port is configured as a DCE device using a female 9-pin D-Sub type connector.
the USB to serial adapter will not work.

You are going to need to get a serial header adapter plate so you can plug into your mainboard. almost all mainboards on a PC do have a header on it for at least 1 RS-232 serial port. they usually do not come with the adapter plate that slides into an expansion slot.
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: Serial control of the Oppo BDP-103

Post by kgschlosser » Sun Aug 19, 2018 6:36 am

now from what I am reading is that the 103 only supports RS-232 control. or so it says. what I find strange is that it also states that you can control it via an app on a portable device. which i do not think that it would use RS-232 for this. If you look at the 203 it too supports the same apps. but it states that is has IP control. if you keep reading it also states that it uses an extended set of codes from the 83 in which the 103 also does. if i had to guess the 103 does have IP control and follows the same guidelines in the 203 IP/RS-232 API. a company is not going to reinvent the wheel with something like this. they will typically use the same hardware/software as other models. there might be an extension of the firmware on that hardware to support different/more control but it should for the most part function the same.

If you give me a little bit i will toss together some code to listen for the UDP discovery broadcast to see if it is in fact broadcasting. if it is then we are good to go. and if not then it does not support IP control.


here is the API for the 203
http://download.oppodigital.com/UDP203/ ... otocol.pdf


*** EDIT

i located the IP API for the 103
I was correct when i stated it is the same as the 203

http://cinema-therapy.de/wp-content/dow ... l_v2.0.pdf
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 547
Joined: Sat Feb 13, 2016 8:39 pm

Re: Serial control of the Oppo BDP-103

Post by jachin99 » Sun Aug 19, 2018 4:25 pm

Thanks for all of the help. It does have an app, and my player didn't come with the remote so the app is my only option at the moment. If need be I can grab a serial card as well. I have had JRiver control the TV via the Stereo control jack on the TV before but we never could get EG to do it. I even tried downloading the one mitsubishi serial control plugin on these forums but it doesn't find the TV. I haven't tried the serial plugin on the TV yet though.

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

Re: Serial control of the Oppo BDP-103

Post by kgschlosser » Sun Aug 19, 2018 5:21 pm

it is up to you what you would like to do. I have almost all of the IP control plugin made for your player. It uses the exact same command structure as the Serial control and both types of control are exactly identical.

I do hate the chinese manufacturers that call the USB to TTL serial adapters USB to RS-232. they really are not. not unless you come across one that plugs into the wall at the same time it is plugged into the USB. It has been a long while since I have seen one of these. The RS-232 ports on AV devices is usually being plugged into by specialty control hardware and not usually a PC. and also because RS-232 has a range of something like 50 or 100 feet. where as TTL is a very short distance. I want to say that RS-232 can handle a voltage drop to 6 volts before it starts to have problems. This is another reason why AV devices use RS-232 and not TTL.

But with the advent of IP control (when companies don't do what Samsung did) It is far superior to RS-232 with a maximum line distance of 100 meters or so. and in most cases people use some kind of hardware to make a serial device network ready if it is not already. so it is almost pointless to use serial if the device has IP control. There are special cases where it is needed. The people that made this player did a smashing job with the API. It is extremely simple it follows a consistent structure all the way through it. it has patterns that can programmatically be accounted for to reduce the code footprint. and as an added benefit the IP control and the serial control share the exact same command structure. So making a plugin that does both IP and serial at the same time is cakewalk
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: Serial control of the Oppo BDP-103

Post by kgschlosser » Sun Aug 19, 2018 5:41 pm

also I know you wanted to learn python. So why don't we do this.


How about this be your first plugin..

You have the whole API for your player. Read it. start off with the connection bits for the IP control. since this is something that can already do.

I will give you a few pointers.

UDP broadcast packets can be a pain. and you also want to make sure that the socket loop that you set up to listen for the discovery packet listens on all IP addresses on the machine. you need to specifically tell it to do this. I have several examples where i use a UDP broadcast packet. latest one is DLNA you should be able to locate an example there. DO not use the code layout for a template for a plugin the code for the DLNA was specifically written to be run in a python script.

I will end you over a script that you can run that will generate a plugin template for you. it is not perfect and will need to have it's output corrected. but it automates most of the basic crap.

Code: Select all

The illustration of the command structure is as the followings: 
<Command> = <Start of Command><Command Code>[<sp><Parameters>]  
<End of Command> 
<Start of Command> = #, ASCII 0x23 
<Command Code> = <byte><byte><byte> 
<sp> = space, ASCII 0x20 
<Parameters> = command-specific 
Now as far as the API goes

when you see a 0x23 or a 0x20 this is a hexadecimal number sometimes the number will map to an ascii character. if that is the case then you can do this one of several ways

simply wrap the character in quotes

Code: Select all

'#'
' '
key the string hexdeimal version of the character

Code: Select all

'\x23'
'\x20'
or use the python chr function

Code: Select all

chr(0x23)
chr(0x20)
for readability and also because API seems to be very specific about the data being bytes
an example is

to turn the power on it would be

Code: Select all

bytearray('REMOTE PON')
and the response is

Code: Select all

'@PON OK'
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 547
Joined: Sat Feb 13, 2016 8:39 pm

Re: Serial control of the Oppo BDP-103

Post by jachin99 » Sun Aug 19, 2018 6:53 pm

I'm happy with either one. I just jumped to conclusions about serial. Ip control is good too

jachin99
Experienced User
Posts: 547
Joined: Sat Feb 13, 2016 8:39 pm

Re: Serial control of the Oppo BDP-103

Post by jachin99 » Sun Aug 19, 2018 7:42 pm

I could try to make a plugin for it, and I think your right that the api looks very approachable.

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

Re: Serial control of the Oppo BDP-103

Post by kgschlosser » Mon Aug 20, 2018 2:40 am

I think that would be a great first official plugin for you. The API is not complex. tho it could have been written differently and also to include the whole command and not pieces of it. If you look at the examples at the end of the API spec you should see what I am talking about. they show it in the examples but it is not mentioned anywhere in the API. This is the single thing that would have to be tested.
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 547
Joined: Sat Feb 13, 2016 8:39 pm

Re: Serial control of the Oppo BDP-103

Post by jachin99 » Tue Aug 21, 2018 12:11 am

Alright, I still have to go back and relearn the basics of python but after looking around at the various socket tutorials, this is what I have come up with thus far. I know its incomplete but I would at least like to think this accomplishes the task of creating a connection. There isn't any error handling, and I haven't created any classes or anything yet but that can come once I learn a little more. I haven't started messing with extracting the IP and Port from the UDP broadcast just yet because I need to learn the basics. I got your message with the plugin generator, and I'll send you a reply as soon as I can. I also installed pycharm because last I checked, it is what was recommended on one of the EG pages. Here is my code thus far:

Code: Select all

import eg
eg.RegisterPlugin(
    name = "Oppo BDP-10X & BDO-10XD IP Control",
    author = "Jachin99",
    version = "0.0.1",
    kind = "Hardware Control",
    description = "This plugin controls the Oppo BDP-103 & 105 and their variants over IP"
)

import socket 

#BASIC COMMANDS

bytearray('REMOTE PON')

bytearray('REMOTE QPW')

bytearray('REMOTE EJT')

bytearray('REMOTE QDT')

bytearray('REMOTE QPL')

bytearray('REMOTE STP') 

bytearray('REMOTE POF') 

bytearray('REMOTE SVM 2')  

bytearray('REMOTE DIM')

bytearray('REMOTE PUR') 

bytearray('REMOTE VUP')

bytearray('REMOTE VDN')

bytearray('REMOTE MUT')

bytearray('REMOTE NU1')

bytearray('REMOTE NU2')

bytearray('REMOTE NU3')

bytearray('REMOTE NU4')

bytearray('REMOTE NU5')

bytearray('REMOTE NU6')

bytearray('REMOTE NU7')

bytearray('REMOTE NU8')

bytearray('REMOTE NU0')

bytearray('REMOTE NU0')

bytearray('REMOTE GOT')

bytearray('REMOTE HOM')

bytearray('REMOTE HOM')

bytearray('REMOTE PUP') 

bytearray('REMOTE PDN')

bytearray('REMOTE OSD')

bytearray('REMOTE TTL')

bytearray('REMOTE MNU')

bytearray('REMOTE NUP')

bytearray('REMOTE NUP')

bytearray('REMOTE NLT')

bytearray('REMOTE NRT')

bytearray('REMOTE NDN')

bytearray('REMOTE SEL')  

bytearray('REMOTE SET')  

bytearray('REMOTE RET')  

bytearray('REMOTE RED')  

bytearray('REMOTE GRN')  

bytearray('REMOTE BLU')

bytearray('REMOTE YLW')  

bytearray('REMOTE STP')

bytearray('REMOTE PLA')  

bytearray('REMOTE PAU')  

bytearray('REMOTE PRE')  

bytearray('REMOTE REV')  

bytearray('REMOTE FWD')  

bytearray('REMOTE NXT')

bytearray('REMOTE AUD')  

bytearray('REMOTE SUB')  

bytearray('REMOTE ANG') 

bytearray('REMOTE ZOM') 

bytearray('REMOTE SAP')

bytearray('REMOTE ATB') 

bytearray('REMOTE RPT')  

bytearray('REMOTE PIP')

bytearray('REMOTE HDM')  

bytearray('REMOTE SUH')  

bytearray('REMOTE NFX')

bytearray('REMOTE VDU')

bytearray('REMOTE OPT')

bytearray('REMOTE M3D') 

bytearray('REMOTE SEH')

bytearray('REMOTE DRB')  

bytearray('REMOTE NOP')


#QUERY COMMANDS

#creates socket for a direct connection to the player

    
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect('192.168.29.44', 48360)
s.bind(('192.168.29.44', 48360))

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

Re: Serial control of the Oppo BDP-103

Post by kgschlosser » Tue Aug 21, 2018 5:16 am

In order to have pycharm work properly you will need to also have python 2.7 installed. make sure you install the 32 bit version


create a folder under %programdata%\eventghost\plugins called OppoDigital
go into that folder.
copy the path in the address bar.
open pycharm.
click on file ----> New project.
select the python 2.7 as the interperter. make sure you do not use virtualenv
when you go to select the folder for the project past in the path you copied from file explorer. PyCharm has a horrid interface for browsing files and folders. this will speed things up.

once done with that click on OK.

on the left hand pane in pycharm click on the + sign next to the project name.
right click on the project name and click on "Add Python File" name the file __init__

Use the Register plugin generator. This way we have a base point.

Last night I added all of the code to create the proper threaded socket connections and what have you. So when you create the plugin do not create any actions. you will want to click on UDP listen and on TCP server. we will have to do some modification. but the bulk of the code will be written at this point.

after you will in the rest of the plugin info at the top click on the view button. this is going to open another window. you will want to copy everything in that window.

go back to pycharm. in the right pane paste in the data from the register plugin generator.

You have now made a plugin that does nothing. LOL
when you click on some other window that is not pycharm it will automatically save everything.

I have already coded up all of the actions. So these I am going to give to you after you have done the steps above. I will explain in detail what is happening with how I did the actions at that point in time.
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 547
Joined: Sat Feb 13, 2016 8:39 pm

Re: Serial control of the Oppo BDP-103

Post by jachin99 » Tue Aug 21, 2018 8:44 pm

I haven't gotten your instructions just right yet but I wanted to note that I'm using these videos on youtube to brush up on python because they introduce both python AND pycharm. The only difference is he uses python 3. https://www.youtube.com/watch?v=IEel7loz-ag

jachin99
Experienced User
Posts: 547
Joined: Sat Feb 13, 2016 8:39 pm

Re: Serial control of the Oppo BDP-103

Post by jachin99 » Thu Aug 23, 2018 12:52 am

It looks like we were successful!! Or at least successful to a point. I didn't have much time to work on this today but I did get this much right. I do have a question though. As I'm importing new packages, should I import them to the default packages location for PyCharm, EG, or both? I tried to test this with wx python but EG kept throwing an error on startup. Thanks again for the help, and here is a capture of the result to make sure everything went correctly.
Capture2.PNG

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

Re: Serial control of the Oppo BDP-103

Post by kgschlosser » Thu Aug 23, 2018 5:58 am

OK so here is the skinny on PyCharm and EG


The 2 do not play nice together. LOL

EG was designed to be run standalone and not from inside of an interpreter. PyCharm will run a code file in an interpreter. That being said you can write a plugin using PyCharm but you cannot run the plugin from inside of PyCharm. This is why i recommended you create a new folder in %programdata%\eventghost\plugins. Then creating a new project inside of PyCharm pointing to that folder. when you make the plugins folder and an __init__.py file you will be able to open and close EG to test the plugin at the same time you are editing the files from inside of PyCharm.

Now if you would like to have the auto complete working when you import eg and type in specific functions/classes I can set this up for you. It is a complex process and I have not designed a simple way to go about it. I will spend some time learning how to set up a custom IDE environment for EG inside of PyCharm in the future.

I can give you the locations/names/versions of python modules you can install that are used in eventghost. this will help in writing plugins. The single biggest crutch EG has when trying to get it to play nice with an IDE is the DynamicModule class in __init__.py as well as having eg added to __builtins__. pycharm does not know how to deal with this taking place. I am sure it can be told about it. that is the part i do not know how to do.

So as an example. that RegisterPuginGenerator that i sent you can be run from inside of EG or it can be run from PyCharm so long as the modules that are needed to run are installed in the python interpreter you have set. EG already has these modules installed.

I am going to recommend you install a package called Numpy this package is going to allow you to enable "scientific mode" in PyCharm. as soon as you install the module it will ask you if you want to switch to that mode. It add a couple of extra features which you will notice right away.
If you like the work I have been doing then feel free to Image

Post Reply