Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
import requests from functools import partial from itertools import cycle from random import randint from typing import Any # todo: convert_func definiert den Typen des Rückgabewerts der Funktion isu _global_cid_generator = cycle(range(1, 0xFFFFFFFF)) def convert_hex(x: str) -> int: return int(x, 16) def convert_not[T](x: T) -> T: return x def isu(ip, index: int, subindex: int = 0, convert_func=convert_not, cid_generator=_global_cid_generator) -> Any: cid = next(cid_generator) response = requests.post( url=f"http://{ip}/iolinkmaster", json={ "code": "request", "cid": cid, "adr": "/iolinkmaster/port[2]/iolinkdevice/iolreadacyclic", "data": { "index": index, "subindex": subindex, }, }, ) response.raise_for_status() data = response.json() try: if int(data.get("code")) != 200: raise RuntimeError("code != 200", data) except ValueError: raise RuntimeError("code is not an integer", data) if data.get("cid") != cid: raise RuntimeError("Got wrong answer", data) return convert_func(data["data"]["value"]) isu("192.168.0.3", 542)
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)