Made corrections to Forms Example

69 views
Skip to first unread message

SonyAPILib

unread,
Apr 13, 2015, 1:28:16 PM4/13/15
to sony-api...@googlegroups.com
Cleaned up the code, added some error checking and corrected a few bugs.

This is ready for Gen 3 testing again!

petewill

unread,
Apr 13, 2015, 10:31:45 PM4/13/15
to sony-api...@googlegroups.com
Looks good!  I was able to launch and control Netfilx from the app.  Very cool!!

A couple of observations (not necessarily issues, just things I noticed):
  1. I have already registered my computer with my TV but when I download the app from github the cookie is (obviously) missing.  This requires me to press "Register" again then Ok when the code prompt appears.  I don't get a code on my TV because the TV thinks it's registered.  If I press Ok without entering a code the cookie is saved and I'm able to control my TV.  Maybe this could be improved a little?
  2. I am noticing very high processor utilization when using the forms app after doing a Discover All but I'm not sure why.  I have attached a screenshot of what's being used.  Please let me know if any other info is required.  It seems to be running normally if I manually load instead of Discover All.
  3. I got an error and the app terminated when I pressed Load (in the Manual Setup) and nothing was there to load (I hadn't yet saved anything).  Maybe there can be some more graceful error instead of terminating?
Good job!

Pete
high processor usage.png

SonyAPILib

unread,
Apr 15, 2015, 2:06:01 PM4/15/15
to sony-api...@googlegroups.com
Thank you for your reply @petewill.

Lets keep in mind that this is only an example application, and shouldn't be considered "Production Ready".
It is basically a way to show others how to use the API in their own forms application.
However, with that said, I DO need to make it more "User Friendly", and be ready to handle any situation.

To answer your comments below:

  1. In most situations, users will not have already registered their devices with this API, so they will not experience this, like we do during our testing!
    But, what we (you) need to do here, is to try to capture a WireShark of this process. I need to see how the device responds back.
    Since it does not display the PIN, it has to be returning some type of information indicating the registration is already there!
    Once we know what it is being sending back, I can make it automatically retrieve the existing cookie from the device, and clean this process up.
    (Will create Issue on GitHub)

  2. I just ran the application on my computer and I can NOT reproduce your findings.
    I have 2 Sony devices, but neither are Gen 3. However, running Discover All only increases my CPU usage during the Discovery process (25%).
    But once the Remote Screen appears, it drops back to 0% - 3%?
    Are you sure it's not something else causing this? Also give me some info about the computer your running it on (32/64 Bit, Windows version, ram....)
    It could also be something to do with an open connection on Gen 3 devices. I will double check the API code and make sure we are not leaving something OPEN or Running in the background.

    I also know that, when you use the Discover All, it will create the _mySony object that contains ALL UPnP services discovered. (Not just Sony's)
    These will be used in future updates to do more things with the devices like send music or a video, read State Variables and respond to device Events.
    However, this could be creating a UPnP service that is constantly looking for new devices or device changes!
    I do NOT see it happening on my computer, so it's hard for me to determine the actual cause.

  3. The Load button should not be ENABLED if there is not a devConfig.bin file in the application folder.
    If you copied or tried to use your old one, this would have happened because I made changes to the devConfig.bin architecture by adding one more field. (Generation)
    Try going to the folder and deleting the devConfig.bin file, and then re-run the application. The load button should be Grayed out until you save a config file.
    Try saving your file, exiting the application. Re_run it and see if the Load button becomes Enabled and loads properly.

    Also, I forgot to tell you that I made more changes to the ActionList_URL input. Instead of leaving it blank, or adding a space, type in the word "null".
    This will now tell the API that the device does NOT have an actionList_URL, and not to try to load one!
Thanks for all your testing help. I couldn't have made it this far without your help!

petewill

unread,
Apr 23, 2015, 10:40:12 PM4/23/15
to sony-api...@googlegroups.com
Sorry for the REALLY delayed response!

I agree about the application not being considered production ready.  It's already great and way more than was out there before!  My thinking behind testing is to list as many items that I find and then let others decide if they actually need to be addressed. 

1. Ok, I did a wireshark capture.  I had to press the Register button twice.  I wasn't prompted with a code on my TV either time but after the second time I was able to control the TV from the Forms.  I emailed you the capture file (I didn't want to upload it to the internet).

2. I'm pretty sure nothing else is causing this as I've only see it happen when I perform a discovery.  I can tell when my processor is being used because my laptop fan starts running very fast.  I almost never hear this during my normal usage.  They only exception is when my antivirus scan is running (which it wasn't doing here).  Computer details: 8 GB RAM, Intel i7 processor, Windows 8.1 64-bit.  I just discovered some additional info.  When I was doing the discover to do the wireshark capture my processor went up to 100% again but when I closed the forms app it went back down (didn't stay at 100%).  The only thing I can guess is last time I had an issue with the forms app crashing and it didn't close everything correctly.  So, I think we can close this issue for now.

3. I renamed the devConfig.bin file and reloaded the app but the load button was still an option.  When I pressed it I got the error. See attached.
Load Config Error.png

SonyAPILib

unread,
Apr 24, 2015, 11:00:19 AM4/24/15
to sony-api...@googlegroups.com
Pete,

Thank you so much for all your help! And don't worry about it! We all have lives and can get very busy.

Yes, the more issues you find the better understanding everyone will have as to what to expect or ways to work around certain outcomes.

1) I got the wireshark and will look thru it and see what I can find.

2) OK! So your not only testing Gen3 devices but also Windows 8. So far I have not seen any issues dealing with 64-bit, but I have heard through other .Net forums that there are some differences in Win 7 & Win 8.
But it could also be due to the Generation 3 code. It is possible that the crash, as you pointed out, caused the Socket to remain OPEN.

3) Have you tried running in debug in VS, and see whats happening here? The error is correct, it can not find the devConfig.bin file. 
However, when this form is loaded, it looks in the folder and checks for the file. If it is NOT there, it is supposed to set the "Load" button's enabled property to FALSE.
I did not write a handler for it, as I thought users would not be able to click it if the file was not there.....
For some reason, on your computer it is either not setting the button's enabled property to false, or it has an issue with the code checking for the file.
This should be located in the Form2.cs file. It appears to work correctly on mine. (Windows 7 Pro i5 64-bit)

Also, I am currently re-packaging the GitHub files to include all 3 examples.
This will allow you to open the project in VS and be able to step through all the example applications without any issues.
I will also be adding some code that will allow you to send a .mp3 or a .mp4 file to the device and it start playing.

Should have this up by the mid of the week. This will all be part of the 5.2 version.

Anyhow, Thanks so much for the update.

Will post my finding soon.

petewill

unread,
Apr 27, 2015, 9:43:59 AM4/27/15
to sony-api...@googlegroups.com
Ok, I just stepped through the debugger.  It looks like the logic is working as it skipped over the load enabled line here:

            if(File.Exists(serializationFile))
            {
                Load_but.Enabled = true;
            }

The load button is still enabled however.  I added these lines:

            else
            {
                Load_but.Enabled = false;
            }

And when I ran it again the load button was disabled.  Maybe Windows 8 handles something differently with the defaults??



On Monday, April 13, 2015 at 11:28:16 AM UTC-6, SonyAPILib wrote:

SonyAPILib

unread,
Apr 27, 2015, 10:12:20 AM4/27/15
to sony-api...@googlegroups.com
Ok,

That's strange, but I guess anything is possible.
It doesn't appear that the default setting was even there, so I don't know why mine worked?

Your solution will work just fine.
You could also go to the Form2.Designer.cs file, scroll down to the Load_but properties and add this line: this.Enabled=false;
This will default the button to false at run-time, every time.


Thanks for your time and help...
Reply all
Reply to author
Forward
0 new messages