Skip to content

Commit 1be2e16

Browse files
authored
Merge pull request #98 from MrClock8163/feature/socket-connection
Add support for socket based connections
2 parents 8b1ab1f + b5a6e5d commit 1be2e16

File tree

18 files changed

+821
-71
lines changed

18 files changed

+821
-71
lines changed

.github/workflows/run-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ env:
88
GEOCOMPY_TEST_PORT_CLIENT: /tmp/geocompy_pty_client
99
GEOCOMPY_TEST_PORT_SERVER: /tmp/geocompy_pty_server
1010
GEOCOMPY_TEST_PORT_FAULTY: /tmp/geocompy_pty_faulty
11+
GEOCOMPY_TEST_TCPPORT_SERVER: 12345
1112

1213
jobs:
1314
testing:
@@ -30,6 +31,7 @@ jobs:
3031
run: |
3132
socat pty,raw,echo=0,link=$GEOCOMPY_TEST_PORT_CLIENT pty,raw,echo=0,link=$GEOCOMPY_TEST_PORT_SERVER &
3233
python tests/com_echo_server.py &
34+
python tests/tcp_echo_server.py &
3335
3436
- name: Test with pytest
3537
run: |

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@ The project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1010
### Added
1111

1212
- Added support for checksums in GeoCOM transactions
13+
- Added `SocketConnection` to allow socket based communication
14+
- Added `open_socket` function to create TCP and RFCOMM socket connections
1315

1416
## Changed
1517

18+
- Changed the `Connection` interface definition to require `send_binary`,
19+
`receive_binary` and `exchange_binary` methods
20+
- Changed `open_serial` to raise `ConnectionRefusedError` instead of the
21+
original exception when the connection could not be opened
22+
- Changed all methods of `SerialConnection` to raise the general
23+
`ConnectionEror` and `TimeoutError` instead of serial specific
24+
`SerialException` and`SerialTimeoutException`
25+
- Changed `GeoCom` init to raise `ConnectionRefusedError` instead of
26+
`ConnectionError` when the connection could not be verified
27+
- Changed `GsiOnlineDNA` init to raise `ConnectionRefusedError` instead of
28+
`ConnectionError` when the connection could not be verified
1629
- Updated GeoCOM response parsing to raise exception when the number of
1730
received paramters does not match the number of parsers specified
1831
- Updated `GeoCom` init signature to require keyword arguments

docs/connections.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,37 @@ If the whole process was successful, the device will be accessible on the
256256
They have to be recreated after every restart either manually, or with
257257
a startup script.
258258

259+
Internet
260+
--------
261+
262+
The newest instruments (in addition to Bluetooth) also come with WLAN support.
263+
This enables connections through TCP/IP.
264+
265+
.. note::
266+
267+
In case of Leica instruments and GeoCOM, the GeoCOM interface on the
268+
instrument might have to be manually switched to WLAN mode
269+
before initiating a connection.
270+
271+
To initiate a connection through internet sockets, the instrument and the
272+
controlling computer must be connected to the same WLAN.
273+
274+
.. tip::
275+
276+
The IP address and TCP port number of the instrument can be checked in the
277+
control menu of the connection settings on the instrument.
278+
279+
.. code-block:: python
280+
:caption: Connection through TCP/IP over WLAN
281+
:linenos:
282+
283+
from geocompy import open_socket
284+
285+
286+
with open_socket("192.168.0.1", 1212, "tcp") as soc:
287+
soc.send("some message")
288+
289+
259290
Simulators
260291
----------
261292

src/geocompy/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
``geocompy.communication.open_serial``
6161
Serial connection context manager function.
6262
63+
``geocompy.communication.open_socket``
64+
Socket connection context manager function.
65+
6366
``geocompy.gsi.dna.GsiOnlineDNA``
6467
DNA instrument implementation.
6568
@@ -86,7 +89,10 @@
8689
Coordinate as Coordinate
8790
)
8891

89-
from .communication import open_serial as open_serial # noqa: F401
92+
from .communication import ( # noqa: F401
93+
open_serial as open_serial,
94+
open_socket as open_socket
95+
)
9096

9197
from .gsi.gsitypes import GsiOnlineResponse as GsiOnlineResponse # noqa: F401
9298
from .gsi.dna import GsiOnlineDNA as GsiOnlineDNA # noqa: F401

0 commit comments

Comments
 (0)