{"id":463,"date":"2017-11-01T08:05:29","date_gmt":"2017-11-01T08:05:29","guid":{"rendered":"http:\/\/buklijas.info\/blog\/?p=463"},"modified":"2018-12-15T10:57:53","modified_gmt":"2018-12-15T10:57:53","slug":"controlling-nec-display-python-nec-pd-sdk","status":"publish","type":"post","link":"http:\/\/buklijas.info\/blog\/2017\/11\/01\/controlling-nec-display-python-nec-pd-sdk\/","title":{"rendered":"Controlling NEC display from Python with nec-pd-sdk"},"content":{"rendered":"

Update on:<\/strong> 07.03.2018
\nUpdated version available on Twilio blog<\/a>.<\/p>\n

Published on:<\/strong> 01.11.2017<\/p>\n

Conclusion<\/h4>\n

pip install nec-pd-sdk<\/code><\/p>\n

My Story<\/h4>\n

I was responsible for maintenance of one spectacular 17 meters tall audio\/video system on a cruise ship.<\/p>\n

The system had 34 NEC X551UN screens<\/a> among other components.<\/p>\n

\"Waterfall<\/p>\n

Behind each screen, there is a SDI-to-DVI converter.<\/p>\n

If a picture on the screen was black, usually there was some problem with SDI-to-DVI converter, mostly power supply was broken.<\/p>\n

Or NEC screen was broken, but I never had it in practice.<\/p>\n

Special NEC screen<\/h4>\n

But, also there was one special screen, it was black from time to time<\/strong>.<\/p>\n

After restart mostly fine, and SDI-to-DVI converter was fine.<\/p>\n

After one month of troubleshooting, I have come to the conclusion that problem is with NEC screen.<\/p>\n

It just got stuck every few days<\/strong> (sometimes every second day, some time was fine for a week), and simple restart (sometimes of 5 seconds and sometimes of 5 minutes) would solve issue till next time.<\/p>\n

I also know that when there is a black picture on this screen, then screen diagnostic was “No signal.”<\/p>\n

\"NEC<\/p>\n

I have come to the conclusion that the following code could solve the problem:<\/p>\n

\nif diagnostic_of_screen is \"no_signal\" is True;\n    turn screen OFF\n    wait 5 minutes\n    turn screen ON    \n<\/pre>\n

And then to run this code on a schedule, like every hour.<\/p>\n

Existing NEC software<\/h4>\n

NEC have two software applications for managing their products.<\/p>\n

First is PD Comms Tool<\/a>, you can remotely get and set all values to a screen.<\/p>\n

It also has a scripting language<\/strong>.<\/p>\n

I have used it for setting scheduler for all 34 screens and change of time.<\/p>\n

It is much faster than manually doing it for each screen.<\/p>\n

The second one is NaViSet Administrator 2<\/a> it is much more powerful than “PD Comms Tool”.<\/p>\n

It can be used for monitoring all your NEC screens and also some additional equipment (like projectors and Windows PC)<\/p>\n

It also has a visual scripting language<\/strong> where you can set and get multiple parameters according to some condition.<\/p>\n

And then you also can set specific scheduler for each script.<\/p>\n

I could have used this tool for my problem, but there was just one problem, it did not have sleep\/pause command.<\/p>\n

Design<\/h4>\n

I know that existing NEC software is communicating with the screen via TCP\/IP.<\/p>\n

Full protocol documentation is at http:\/\/www.necdisplay.com\/documents\/UserManuals\/External_Control_P.V.X-series.pdf<\/a>, but I was not so eager to write custom TCP\/IP packets.<\/p>\n

I wanted something more readable and simple<\/strong>.<\/p>\n

I googled “NEC python” and found about nec-pd-sdk<\/a>, what is python SDK for NEC screens.<\/p>\n

There is no textual documentation, but there are few examples<\/a>.<\/p>\n

Most useful for me was test_routines_example.py<\/a>, it is showing how to get every parameter.<\/p>\n

The command for turning screen ON and OFF<\/strong> was found in source code<\/a>.<\/p>\n

Code for turning NEC screen ON and OFF<\/h4>\n

Here is the code:<\/p>\n

\nfrom __future__ import print_function\nfrom nec_pd_sdk.nec_pd_sdk import NECPD\nfrom nec_pd_sdk.protocol import PDError\nfrom nec_pd_sdk.constants import PD_POWER_STATES\nimport time  # for sleep\nimport sys\n\n\ndef get_screen_state(pd):\n    state = pd.command_power_status_read()\n    text_list = pd.helper_self_diagnosis_status_text()\n    return {'status': state, 'diagnosis': text_list}\n\n\ndef main():\n    try:\n        pd = NECPD.open('192.168.1.52')\n\n        monitor_id = 1\n        pd.helper_set_destination_monitor_id(monitor_id)\n\n        try:\n            screen_state = get_screen_state(pd)\n\n            # 'Normal; '      'No signal; '\n            if screen_state['diagnosis'] == 'No signal; ':\n                \n                # OFF\n                pd.command_power_status_set(PD_POWER_STATES['Off'])\n\n                # pause\n                time.sleep(5 * 60)  # 5 minutes\n\n                # ON\n                pd.command_power_status_set(PD_POWER_STATES['On'])  # 1\n\n        finally:\n            # make sure to always close\n            pd.close()\n\n    except PDError as msg:\n        print(\"PDError:\", msg)\n    return\n\n\nif __name__ == '__main__':\n    main()\n\n# https:\/\/github.com\/pyinstaller\/pyinstaller\/issues\/1687\nsys.exit()  \n<\/pre>\n

Last Words<\/h4>\n

When I was investigating NaViSet Administrator 2<\/a> for my use-case.<\/p>\n

I contacted NEC support, to ask can them can I use it for this purpose.<\/p>\n

They told me not and suggested to use TCP\/IP External_Control<\/a>.<\/p>\n

So, even support from NEC does not know that they have NEC python SDK<\/a>.<\/p>\n

What is sad, considering that their NEC python SDK<\/a> is useful software.<\/p>\n

Questions and remarks, please leave in comments.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"

Update on: 07.03.2018 Updated version available on Twilio blog. Published on: 01.11.2017 Conclusion pip install nec-pd-sdk My Story I was responsible for maintenance of one spectacular 17 meters tall audio\/video system on a cruise ship. The system had 34 NEC X551UN screens among other components. Behind each screen, there is a SDI-to-DVI converter. If a […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[27],"tags":[28,4],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"yoast_head":"\nControlling NEC display from Python with nec-pd-sdk - Sasa Buklijas<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/buklijas.info\/blog\/2017\/11\/01\/controlling-nec-display-python-nec-pd-sdk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Controlling NEC display from Python with nec-pd-sdk - Sasa Buklijas\" \/>\n<meta property=\"og:description\" content=\"Update on: 07.03.2018 Updated version available on Twilio blog. Published on: 01.11.2017 Conclusion pip install nec-pd-sdk My Story I was responsible for maintenance of one spectacular 17 meters tall audio\/video system on a cruise ship. The system had 34 NEC X551UN screens among other components. Behind each screen, there is a SDI-to-DVI converter. If a […]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/buklijas.info\/blog\/2017\/11\/01\/controlling-nec-display-python-nec-pd-sdk\/\" \/>\n<meta property=\"og:site_name\" content=\"Sasa Buklijas\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-01T08:05:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-12-15T10:57:53+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/buklijas.info\/blog\/wp-content\/uploads\/2017\/10\/waterfall_top.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\">\n\t<meta name=\"twitter:data1\" content=\"Sasa Buklijas\">\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data2\" content=\"3 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/buklijas.info\/blog\/#website\",\"url\":\"http:\/\/buklijas.info\/blog\/\",\"name\":\"Sasa Buklijas\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"http:\/\/buklijas.info\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"http:\/\/buklijas.info\/blog\/2017\/11\/01\/controlling-nec-display-python-nec-pd-sdk\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/i0.wp.com\/buklijas.info\/blog\/wp-content\/uploads\/2017\/10\/waterfall_top.jpg?fit=1296%2C968\",\"width\":1296,\"height\":968},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/buklijas.info\/blog\/2017\/11\/01\/controlling-nec-display-python-nec-pd-sdk\/#webpage\",\"url\":\"http:\/\/buklijas.info\/blog\/2017\/11\/01\/controlling-nec-display-python-nec-pd-sdk\/\",\"name\":\"Controlling NEC display from Python with nec-pd-sdk - Sasa Buklijas\",\"isPartOf\":{\"@id\":\"http:\/\/buklijas.info\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/buklijas.info\/blog\/2017\/11\/01\/controlling-nec-display-python-nec-pd-sdk\/#primaryimage\"},\"datePublished\":\"2017-11-01T08:05:29+00:00\",\"dateModified\":\"2018-12-15T10:57:53+00:00\",\"author\":{\"@id\":\"http:\/\/buklijas.info\/blog\/#\/schema\/person\/780025d597f1c5df3cc156eaffc8c561\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/buklijas.info\/blog\/2017\/11\/01\/controlling-nec-display-python-nec-pd-sdk\/\"]}]},{\"@type\":\"Person\",\"@id\":\"http:\/\/buklijas.info\/blog\/#\/schema\/person\/780025d597f1c5df3cc156eaffc8c561\",\"name\":\"Sasa Buklijas\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"http:\/\/buklijas.info\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/0.gravatar.com\/avatar\/9f6f7de5a4882517ca0e4a8ebd607925?s=96&d=mm&r=g\",\"caption\":\"Sasa Buklijas\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5YHGV-7t","_links":{"self":[{"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/posts\/463"}],"collection":[{"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/comments?post=463"}],"version-history":[{"count":38,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/posts\/463\/revisions"}],"predecessor-version":[{"id":795,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/posts\/463\/revisions\/795"}],"wp:attachment":[{"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/media?parent=463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/categories?post=463"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/tags?post=463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}