Use of a ceiling clock as a bulletin board


At the end of 2013, our company moved to a new office in one of the towers of the Moscow-City complex. As a legacy from the past tenant of the premises, we got a ceiling clock designed to display time in various time zones. Apparently, the tenant was tied to the financial or banking sector.

At first we tried to reconfigure the clock (to correct the time and change the displayed cities), but could not do it - a monolithic aluminum box hung on the ceiling without any controls. Subsequently, the clock was de-energized and left hanging without signs of life. Two years later, they got the idea to revive the clock and use it as something more.

Ceiling clock

Device identification

The first problem on the way was the need to identify the device - we did not know the watch model or its manufacturer. No identification marks, stickers and engravings on the device’s body could be found. Documentation for the device was also missing.

At this moment, we came to the conclusion that opening the box, starting from the sides, is necessary to identify the device. The bolt heads were damaged during the first attempt to open two years ago. One of the bolts could not be unscrewed - I had to break the corner of the panel. Fortunately, it is made of soft aluminum, so that it was possible to inflict minimal visual and structural damage to the structure.

Broken corner of the watch
Broken corner

Inside was a web of wires and a scattering of control boards. On one of them, we were able to look for the name of the manufacturer of the Wharton watches, on the website of which our copy was determined by visual signs .

The inside of the watch
The inside of the watch

On the manufacturer’s website, the consumer support section is limited to the contact details of the organization, which is headquartered in the UK. After ten minutes of talking on the phone with a second support line, we were sent a watch instruction, where the procedure for setting the clock using the remote control was described in detail. The tenants did not leave us the remote control.

After another ten minutes of conversation with the support service, we were sent a proprietary utility designed to set the clock, set time zones, set a signature over sections, and also to synchronize time. The program communicates with the clock via a regular COM port, which was kindly hidden by the installers under the false ceiling above the clock. For our instance, the program worked off with a bang.

Wharton ZoneControl 1.7

In the process of studying the insides of the watch, a set of jumpers was noticed on the control board of each section. Having played with the utility and jumpers, we found out that they control the internal number of the section, which allows you to display the same information and time on different sections. This feature is relevant for our bilateral sample - time and text are duplicated on both sides.

Watch management program

It's time to move on to the entertaining part of the exercise: analyzing the algorithm of the tuning program in order to write your own control program. There are several ways to approach this task. First, we considered the option of disassembling the official utility. After several attempts to understand the assembler code, they decided to follow the path of reverse engineering the data transfer protocol: to study and understand the data that is transmitted via the COM cable.

Wharton ZoneControl: HABR test 1
Wharton ZoneControl: HABR test 2

To study the commands transmitted via the COM port, we used the program HDD Software Device Monitoring Studio. The program clings to the COM port installed in the system, without violating the mode of its operation, removes the data transmitted on the port and automatically splits it into data packets based on delays between transmissions. With the studio running, we removed traffic from the setup program for the clock:

COM port traffic

For the purposes of the project, a change of time zone is not required, therefore only the first part of the request was studied in detail. By trial and error, it was possible to parse the structure of the first part of the request in more detail:

Data Packet Breakdown

The beginning and end of a team are constant values ​​for all teams. In the ASCII table, these codes correspond to the characters “start of text” and “end of text”. The scoreboard code makes sense if several scoreboards are connected by a chain. In our case, the scoreboard is only one, because for us, in the sense, the value is a constant. There are several command codes (“set text”, “set time zone”, “synchronize time”), for our project only “ 0x83- set text” is used. Based on the formula used to section numbers: 0x80 + номер_секции – 1.

For the text sections usually used conversion: 0x80 | ord(символ). The watch supports a small set of characters to display: numbers, Latin letters, lowercase and uppercase, space, special characters and punctuation marks. Cyrillic is not wired into the system. Text is limited to ten characters and is constant. If the length of the displayed string is less than ten characters, then you need to “finish” the string to the full length with spaces. When displaying text on a watch, spaces at the beginning and end of a line are ignored, and the text itself is centered when rendering. If the character code is not supported, the “!” Symbol is displayed.

A check bit is present at the end of each command. For the team that interests us, the formula for calculating the check digit is the character XOR for the text and section number (already encoded). For the received value, the high and low octets are written in separate bytes of the control bit of the message. Visual example:

control discharge formation

The algorithm was verified through a proof-of-concept script written in PHP that writes the appropriate commands directly to the COM port. Using this script, we specified the minimum allowable delays between teams, in particular, we managed to minimize the delay between teams from one second (standard in the program from the supplier) to 300 ms, and also checked the alphabet supported by the clock.

Access the watch over the network

Interaction with the watch program was only one part of the problem, although the most difficult. To ensure the success of the project, it was necessary to be able to send control commands to the watch via the network. In the end, we could not leave the test laptop connected to the 24x7 watch.
To implement a network connection, it was decided to create a simple C # program that opens a TCP port and waits for an external connection. When a command is received over the network, the program performs the following operations:

  1. sets a lock (to exclude parallel work with the clock);
  2. opens a local COM port on which the clock hangs;
  3. sends a command;
  4. closes the port;
  5. waiting for a pre-configured time (as set above - 300 ms);
  6. unlocks;
  7. sends confirmation of command execution.

Initially, the idea was to provide a direct connection to the COM port over the network (i.e., implement a tcp2com solution ). Such an approach could allow sending any commands to the watch and experimenting with the device. But in the end, this idea was abandoned in favor of implementing a service program that implements all the coding and clock management logic.

self-written management program

The compiled program implements an XML interface, accepts requests through standard for C # HttpListener. The format of messages over the network involves specifying the section to configure and the displayed text:

[section number]
[section text]

The written program was installed on a Windows server, locked in the technical room of the office. Since the server is at some distance, we dragged 10 meters of CAT5 wires under the false ceiling from the clock to the utility room. The CAT5 cable was used as a signal COM cable (only two wires were used). There were feelings that ten meters of wire for a watch is too much, but, fortunately, the connection worked without problems. The Windows server itself is connected to the internal network of the company and has a static address. Simple testing from a browser on the internal network confirmed the presence of communication and the correct operation of both the program and the connection with the clock.

Display useful information

The watch is connected and is now available online as a web service. It's time to print useful information!

Для интеграции с внешними источниками данных взяли развёрнутую в нашем офисе корпоративную шину SAP Process Integration 7.4. На момент запуска проекта в эксплуатацию мы взяли три источника данных:

  1. Центробанк России;
  2. Гидрометцентр России;
  3. Яндекс.Пробки.

Система SAP PI занимается опросом по расписанию внешних источников, преобразованием данных и последующей передачей результата на часы.

For the Central Bank, we take once an hour the latest published data on the exchange rate of the euro and US dollars. Once every 15 minutes for the Hydrometeorological Center, we collect information from a weather station located in the vicinity of the Kievskaya metro station - the nearest weather station in open access to our office. Of the available attributes, we display only the temperature and relative humidity. The Yandex.Traffic service updates every 15 minutes and displays the current state of traffic congestion for Moscow as a whole.

And now - photo finish!

Information table

Also popular now: