MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / configure_network

Method configure_network

tests/utils/api_client.py:255–282  ·  view source on GitHub ↗

Configure network driver for device simulation.

(
        self,
        host: str = "127.0.0.1",
        port: int = 9000,
        socket_type: str = "tcp",
    )

Source from the content-addressed store, hash-verified

253 self.command("io.setBusType", {"busType": bus_map[bus_type.lower()]})
254
255 def configure_network(
256 self,
257 host: str = "127.0.0.1",
258 port: int = 9000,
259 socket_type: str = "tcp",
260 ) -> None:
261 """Configure network driver for device simulation."""
262 socket_type_map = {"tcp": 0, "udp": 1}
263
264 commands = [
265 {"command": "io.setBusType", "params": {"busType": 1}},
266 {"command": "io.network.setRemoteAddress", "params": {"address": host}},
267 {
268 "command": "io.network.setSocketType",
269 "params": {"socketTypeIndex": socket_type_map[socket_type.lower()]},
270 },
271 ]
272
273 if socket_type.lower() == "tcp":
274 commands.append(
275 {"command": "io.network.setTcpPort", "params": {"port": port}}
276 )
277 else:
278 commands.append(
279 {"command": "io.network.setUdpRemotePort", "params": {"port": port}}
280 )
281
282 self.batch(commands)
283
284 def connect_device(self) -> None:
285 """Connect to the configured device."""

Calls 2

batchMethod · 0.95
appendMethod · 0.45