# Led and Switch Access in CC100

**URL:** <https://www.wago.community/t/led-and-switch-access-in-cc100/632>\
**Category:** Node-RED\
**Created:** [October 10, 2023, 8:50am UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632 "2023-10-10T08:50:28Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://www.wago.community/u/iiot2k)\
**Post date:** [October 10, 2023, 8:50am UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/1 "2023-10-10T08:50:28Z")

</div>

How can you address the LEDs of the CC100 via the Led Server programmatically in C++?

There is a Run/Stop/Reset switch on the CC100, how can you read this switch programmatically in C++?

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![WagoKurt](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagokurt/32/11_2.png) [@WagoKurt](https://www.wago.community/u/WagoKurt)\
**Post date:** [October 12, 2023, 3:58pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/2 "2023-10-12T15:58:36Z")

</div>

![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/b54e494b573725a5115c4a31195da1abda5d139a.png)  
There are some command line tools to read the USR LED and RunStop Switch. I don’t know of an API to write to the LED outside of Codesys at this point.

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://www.wago.community/u/iiot2k)\
**Post date:** [October 16, 2023, 12:07pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/3 "2023-10-16T12:07:21Z")

</div>

Thanks @WagoKurt for the tip.  
I will probably postpone the control of the LED and Key in my Node-Red node until later.

---

<div class="post-metadata">

**Author:** ![VegardS](https://avatars.discourse-cdn.com/v4/letter/v/a88e57/32.png) [@VegardS](https://www.wago.community/u/VegardS)\
**Post date:** [October 16, 2023, 2:03pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/4 "2023-10-16T14:03:51Z")

</div>

Turning on/off the LEDs can be done using the linux kernel class for leds.  
The individual leds can be accessed from `/sys/class/leds/`  
For example turning on the green run-led:

```auto
echo 255 > /sys/class/leds/run-green/brightness

```

Write 0 to turn off.

The OP-mode switch input can also be monitored by listening on the following event:

```auto
/dev/input/event0

```

I was doing some poking around on this event but I’m not quite sure how the data is packed. It might be something like this:

```auto
struct input_event {
    struct timeval time;
    unsigned short type;
    unsigned short code;
    unsigned int value;
};

```

You can do the following to listen on the event in terminal:

```auto
cat /dev/input/event0 | hexdump -C 

```

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://www.wago.community/u/iiot2k)\
**Post date:** [October 16, 2023, 3:23pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/5 "2023-10-16T15:23:34Z")

</div>

I will add the RUN and USR LEDs to the node in the next version.  
But sometimes there are problems with write permissions in Docker in Node-Red.  
Hardware Events in Node-Red is a tricky thing, so I’ll wait until I have more information.  
Thanks @VegardS for the hint.

---

<div class="post-metadata">

**Author:** ![VegardS](https://avatars.discourse-cdn.com/v4/letter/v/a88e57/32.png) [@VegardS](https://www.wago.community/u/VegardS)\
**Post date:** [October 16, 2023, 5:09pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/6 "2023-10-16T17:09:54Z")

</div>

I also found this HowTo which might be helping you decoding the OMS.

> <https://github.com/WAGO/pfc-howtos/blob/master/HowTo_ReadOperatingModeSwitches/pfc/src_omsreader/omsreader.c>

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://www.wago.community/u/iiot2k)\
**Post date:** [October 20, 2023, 8:26am UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/7 "2023-10-20T08:26:53Z")

</div>

I added the Run and User1 leds to the nodes.  
Thank you @VegardS and @WagoKurt for the tips.  
I will add the switch query later because the wago\_oms\_API.c file is missing.  
Hopefully I can get the Ladder Logic Nodes online this weekend.  
I also added some notes about the CC100 to my Github page:

> **[GitHub - redplc/cc100: Notes about Wago Controller CC100](https://github.com/redplc/cc100)**
>
> Notes about Wago Controller CC100. Contribute to redplc/cc100 development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![quenorha](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/quenorha/32/429_2.png) [@quenorha](https://www.wago.community/u/quenorha)\
**Post date:** [October 24, 2023, 5:25am UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/8 "2023-10-24T05:25:26Z")

</div>

Hello,  
You’ll find my notes concerning LEDs :  
LEDs can be controlled by using /sys/class/leds folder.  
When calling other LEDs than user LEDs, the ledserver should be disabled.

Depending on the device LEDs are named in a different manner :

**PFC**

| U1 | pca955x:u1-[color] |
| --- | --- |
| … | |
| U7 | pca955x:u7-[color] |
| SYS | pca955x:sys-[color] |
| RUN | pca955x:run-[color] |
| IO | pca955x:io-[color] |
| MS | pca955x:ms-[color] |
| NS | pca955x:ns-[color] |

**TP600**

| SYS (front) | sys-[color] |
| --- | --- |
| SYS (back) | pca955x:sys-[color]-back |
| RUN | pca955x:run-[color] |
| H11 | pca955x:h11-[color] |
| H12 | pca955x:h12-[color] |
| CAN | pca955x:can-[color] |
| Brightness - | pca955x:bright-minus |
| Brightness + | pca955x:bright-plus |

**CC100**

| USER | u1-[color] |
| --- | --- |
| SYS | sys-[color] |
| RUN | run-[color] |
| MMC | led-mmc |

**Switch ON / OFF**

```auto
echo 255 > [path/to/led]/brightness 
echo 0 > [path/to/led]/brightness

```

Ex :

```auto
echo 255 > /sys/class/leds/pca955x:u1-green/brightness 
echo 0 > /sys/class/leds/pca955x:u1-green/brightness

```

**BLINK (Start & Stop)**

```auto
echo timer > [path/to/led]/trigger
echo none > [path/to/led]/trigger

```

Ex :

```auto
echo timer > /sys/class/leds/pca955x:u1-green/trigger
echo none > /sys/class/leds/pca955x:u1-green/trigger

```

---

<div class="post-metadata">

**Author:** ![WagoKurt](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagokurt/32/11_2.png) [@WagoKurt](https://www.wago.community/u/WagoKurt)\
**Post date:** [October 24, 2023, 7:08pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/10 "2023-10-24T19:08:34Z")

</div>

Does anyone know how to read the reset switch position?

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://www.wago.community/u/iiot2k)\
**Post date:** [October 24, 2023, 9:21pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/11 "2023-10-24T21:21:59Z")

</div>

The control of the user and run LEDs are already implemented in the CC100 node.  
Thanks for info.

---

<div class="post-metadata">

**Author:** ![VegardS](https://avatars.discourse-cdn.com/v4/letter/v/a88e57/32.png) [@VegardS](https://www.wago.community/u/VegardS)\
**Post date:** [October 31, 2023, 6:20pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/12 "2023-10-31T18:20:39Z")

</div>

@WagoKurt @iiot2k  
I did some research and decoding of the events generated in `/dev/input/event0`, and here is my notes:

**Example events**  
`cat /dev/input/event0 | hexdump -C`  
_Note that hexdump is swapping the bytes_

```auto
         | 8 bytes system time |type |code | value |
Event 1: |27 0c 41 65 9a dd 0a 00|05 00|02 00|00 00 00 00|
Event 2: |27 0c 41 65 9a dd 0a 00|00 00|00 00|00 00 00 00|
Event 3: |27 0c 41 65 2c e4 0a 00|05 00|01 00|01 00 00 00|

```

This matches the following structure:

```auto
struct input_event {
    struct timeval time;
    unsigned short type;
    unsigned short code;
    unsigned int value;
};

```

**Event Type** , in this case will be of the following types:

```auto
Type 0: EV_SYN - Used as markers to separate events.
Type 1: EV_KEY - Used to describe state changes of keyboards, buttons, or other key-like devices.
Type 5: EV_SW - Used to describe binary state input switches.

```

> Source:  
> [https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h](https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h)  
> [https://www.kernel.org/doc/Documentation/input/event-codes.txt](https://www.kernel.org/doc/Documentation/input/event-codes.txt)

`EV_KEY` is used on push buttons, like “oms drag-down reset” or the RST button.  
`EV_SW` is used on the run and stop states of the “oms”.

**Code** , will be any of the following values:

```-
0x01: Run
0x02: Stop
0x03: Reset
0x04: RST Button

```

**Value** , will be any of the following values:

```-
0x00: Off
0x01: On
0x02: Hold (Reset and RST Buttons), event is repeated as long as button is held.

```

Using this information, the example events can be decoded;  
**First event:**  
The code is 0x02, which is the stop state, and the value is 0x00 (off), ie. the swich is not in stop pos.

**Second event:**  
The type (and code) is 0x00, which is just a event separator and can thus be disregarded in this case.

**Third event:**  
The code is 0x01, which is the run state and the value is 0x01 (on), ie. the switch is in run pos.

_Concluding_: the switch was moved from stop to run.

Using this information, it should be fairly simple to create a python, c/c++ program or whatever to give state on all front buttons of the PLCs for use in custom applications.

Beware that there is an “oms daemon” running in the background, causing the RST button to set fixed ip if held long enough etc …

The oms-daemon (`/usr/bin/omsd`) is started/stopped by `/etc/rc.d/S01_omsdaemon` and `/etc/init.d/omsdaemon`.

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://www.wago.community/u/iiot2k)\
**Post date:** [November 1, 2023, 5:27am UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/13 "2023-11-01T05:27:24Z")

</div>

Thanks for your explanations. I will integrate the key query into my node-red node. Each array element will get boolean true/false for run and stop. Should I also query reset?

---

<div class="post-metadata">

**Author:** ![WagoKurt](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagokurt/32/11_2.png) [@WagoKurt](https://www.wago.community/u/WagoKurt)\
**Post date:** [November 17, 2023, 8:20pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/14 "2023-11-17T20:20:59Z")

</div>

This link is a related topic, how to R/W to the CC100 IO.

[https://www.wago.community/t/r-w-cc100-from-cli/681](https://www.wago.community/t/r-w-cc100-from-cli/681)

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://www.wago.community/u/iiot2k)\
**Post date:** [November 18, 2023, 11:25am UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/15 "2023-11-18T11:25:54Z")

</div>

Thanks @WagoKurt for the interesting document.  
The functions described are already implemented in the node @redplc/node-red-wago-cc100-io.  
I’m in the process of integrating the key function into the node as @VegardS described.  
I have the following problem:  
If you read from /dev/input/event0, the call is blocked until a key event occurs.  
Of course that would also block Node-Red.  
The solution will not be easy and complex.

---

<div class="post-metadata">

**Author:** ![VegardS](https://avatars.discourse-cdn.com/v4/letter/v/a88e57/32.png) [@VegardS](https://www.wago.community/u/VegardS)\
**Post date:** [November 18, 2023, 11:45am UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/16 "2023-11-18T11:45:38Z")

</div>

Im not familiar with node red plugin development, but polling for such events must be done asynchronously in order to not block the node red event loop.

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://www.wago.community/u/iiot2k)\
**Post date:** [November 30, 2023, 3:26pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/17 "2023-11-30T15:26:45Z")

</div>

Hi,  
I add the key read in Node-Red Node:

> **[@redplc/node-red-wago-cc100-io](https://flows.nodered.org/node/@redplc/node-red-wago-cc100-io)**
>
> Node-RED nodes for Wago CC100 I/O using with redPlc nodes.

---

<div class="post-metadata">

**Author:** ![ssavov](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@ssavov](https://www.wago.community/u/ssavov)\
**Post date:** [November 14, 2024, 3:18pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/18 "2024-11-14T15:18:50Z")

</div>

Hello,  
Does anyone know how to control the USER LED on a Wago CC100 from Codesys?

Thanks!

---

<div class="post-metadata">

**Author:** ![Lauri](https://avatars.discourse-cdn.com/v4/letter/l/9f8e36/32.png) [@Lauri](https://www.wago.community/u/Lauri)\
**Post date:** [November 15, 2024, 12:01pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/19 "2024-11-15T12:01:53Z")

</div>

Hi!  
The library WagoAppAppLED is your friend 🙂

---

<div class="post-metadata">

**Author:** ![ssavov](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@ssavov](https://www.wago.community/u/ssavov)\
**Post date:** [November 15, 2024, 2:20pm UTC](https://www.wago.community/t/led-and-switch-access-in-cc100/632/20 "2024-11-15T14:20:28Z")

</div>

Thanks, Lauri!  
Sorry for such a dumb question, but I’m new to CODESYS and WAGO.  
🙂
