❌ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayNews from the Ada programming language world

An interesting thing happened to me yesterday.

TLDR: Ada is a great language!

I thought I would share. So, a PLC (Mitsubishi FX5UC) was brought to my work table yesterday. I was supposed to try to establish communication with it. I wrote a Missubishi communication driver back in 2021 for our SCADA system. In Ada, naturally, as most of our system is in Ada :)

The communication can be either via UDP or TCP, somewhat similar but more complicated than Modbus (more addressing modes, more types of variables). In 2021, it took me some 10 man-days to write using the available Mitsubishi documentation (500 pages) which is so good it even contains packet samples (which I used for dry tests as at the time, I had no available Mitsubishi PLC). The result was some 80 kB source file (adb) with a small 3kB specification (ads). (I don't count changes needed to add a new communication protocol to the SCADA).

Now, after yesterday's testing I had to:

  • replace calling one socket-reading function with another (mistakenly I used 'read until the output buffer is full' instead of 'read what data is available')
  • add one line (multiplication by 2) handling the fact that a word register has 2 bytes
  • add 'else' branch to initialize a variable
  • modify 2 comments (a reference to a wrong page of Mitsubishi documentation)
  • to make writing to a bit variable work, change a constant (2#0001_0000" instead of 1 as a high nibble is used for the 1st bit, low for the second bit).

That's all. After 2.5 hours I was able to read/write all the required variable types. After another 2.5 hours, I checked all the types in our driver documentation (and discovered one more typo - one of the variable types was a word instead of a bit).

I'm no great programmer and I usually generate quite a lot of mistakes, so this time I was pleasantly surprised that with a few corrections, my code actually started to work quite quickly. I think the choice of a programming language has a lot to do with it ... ;-)

submitted by /u/PeterHumaj
[link] [comments]
❌
❌