Skip to content

Commit adc20b2

Browse files
authored
Merge pull request #20 from CommonplaceRobotics/hello_message
Send Hello message in connect function
2 parents eb5a71e + 0aa5200 commit adc20b2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cri_lib/cri_controller.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import socket
33
import threading
4+
from datetime import datetime, timezone
45
from enum import Enum
56
from pathlib import Path
67
from queue import Empty, Queue
@@ -73,7 +74,13 @@ def __init__(self) -> None:
7374
}
7475
self.jog_speeds_lock = threading.Lock()
7576

76-
def connect(self, host: str, port: int = 3920) -> bool:
77+
def connect(
78+
self,
79+
host: str,
80+
port: int = 3920,
81+
application_name: str = "CRI-Python-Lib",
82+
application_version: str = "0-0-0-0",
83+
) -> bool:
7784
"""
7885
Connect to iRC.
7986
@@ -83,6 +90,10 @@ def connect(self, host: str, port: int = 3920) -> bool:
8390
IP address or hostname of iRC
8491
port : int
8592
port of iRC
93+
application_name : str
94+
optional name of your application sent to controller
95+
application_version: str
96+
optional version of your application sent to controller
8697
8798
Returns
8899
-------
@@ -105,6 +116,10 @@ def connect(self, host: str, port: int = 3920) -> bool:
105116
# Start sending ALIVEJOG message
106117
self.jog_thread.start()
107118

119+
hello_msg = f'INFO Hello "{application_name}" {application_version} {datetime.now(timezone.utc).strftime(format="%Y-%m-%dT%H:%M:%S")}'
120+
121+
self._send_command(hello_msg)
122+
108123
return True
109124

110125
except ConnectionRefusedError:

0 commit comments

Comments
 (0)