Read and write descriptive comments (labels) for registers and I/O ports on your Fanuc robot.

## SNPX

SNPX reads and writes comments for all register and I/O types:

**C# : ReadWriteIoCommentsSnpx**
```csharp
using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Snpx.Internal;
using UnderAutomation.Fanuc.Snpx;

public class ReadWriteIoCommentsSnpx
{
    static void Main()
    {
        FanucRobot robot = new FanucRobot();
        robot.Connect("192.168.0.1");

        /**/
        // Read a comment (default 16 characters)
        string comment = robot.Snpx.Comments.Read(CommentType.Register, 5);

        // Read with custom length (must be even, >= 2)
        string longComment = robot.Snpx.Comments.Read(CommentType.Register, 5, 24);

        // Write a comment
        robot.Snpx.Comments.Write(CommentType.PositionRegister, 1, "Home Position", 16);
        robot.Snpx.Comments.Write(CommentType.DI, 1, "Start Button", 16);
        /**/
    }
}
```

**Python : ReadWriteIoCommentsSnpx**
```python
from underautomation.fanuc.fanuc_robot import FanucRobot

robot = FanucRobot()
robot.connect("192.168.0.1")

##
# Read a comment (default 16 characters)
comment = robot.snpx.comments.read("Register", 5)

# Read with custom length (must be even, >= 2)
long_comment = robot.snpx.comments.read("Register", 5, 24)

# Write a comment
robot.snpx.comments.write("PositionRegister", 1, "Home Position", 16)
robot.snpx.comments.write("DI", 1, "Start Button", 16)
##
```

Available comment types: `Register`, `PositionRegister`, `StringRegister`, `DI`, `DO`, `RI`, `RO`, `UI`, `UO`, `SI`, `SO`, `WI`, `WO`, `WSI`, `WSO`, `GI`, `GO`, `AI`, `AO`, `Flag`.

See also: [SNPX Alarms & task status](/fanuc/documentation/snpx-alarms-tasks)

## CGTP Web Server

CGTP provides bulk comment reading and individual writing:

**C# : ReadWriteIoCommentsCgtp**
```csharp
using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Cgtp;
using UnderAutomation.Fanuc.Common;

public class ReadWriteIoCommentsCgtp
{
    static void Main()
    {
        FanucRobot robot = new FanucRobot();
        robot.Connect("192.168.0.1");

        /**/
        // Read all register comments
        string[] regComments = robot.Cgtp.GetComments(CgtpCommentType.NumericRegister);
        string[] posComments = robot.Cgtp.GetComments(CgtpCommentType.PositionRegister);

        // Write a comment
        robot.Cgtp.SetComment(CgtpCommentType.NumericRegister, 1, "Speed setpoint");

        // Read I/O comments by category
        IOComments digitalIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.DigitalIO);
        IOComments robotIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.RobotIO);
        IOComments groupIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.GroupIO);
        IOComments analogIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.AnalogIO);
        /**/
    }
}
```

**Python : ReadWriteIoCommentsCgtp**
```python
from underautomation.fanuc.fanuc_robot import FanucRobot

robot = FanucRobot()
robot.connect("192.168.0.1")

##
# Read all register comments
reg_comments = robot.cgtp.get_comments("NumericRegister")
pos_comments = robot.cgtp.get_comments("PositionRegister")

# Write a comment
robot.cgtp.set_comment("NumericRegister", 1, "Speed setpoint")

# Read I/O comments by category
digital_io = robot.cgtp.get_io_comments("DigitalIO")
robot_io = robot.cgtp.get_io_comments("RobotIO")
group_io = robot.cgtp.get_io_comments("GroupIO")
analog_io = robot.cgtp.get_io_comments("AnalogIO")
##
```

See also: [CGTP Alarms, comments & files](/fanuc/documentation/cgtp-alarms-files)

## Protocol comparison

| Feature | SNPX | CGTP |
|---------|------|------|
| **Read individual** | Yes | No (bulk only) |
| **Read all** | No | Yes |
| **Write** | Yes | Yes |
| **Register comments** | Yes | Yes |
| **I/O comments** | Yes | Yes (by category) |
| **Custom length** | Yes (even, ≥ 2) | No (fixed) |