DiamondLightSource / FastCS

Control system agnostic framework for building device support in Python for both EPICS and Tango
Apache License 2.0
1 stars 2 forks source link

Add serial connection #34

Closed marcelldls closed 4 months ago

marcelldls commented 4 months ago

I tested this against both a virtual serial device (based on https://stackoverflow.com/questions/52187/virtual-serial-port-for-linux) as well as some hardware (Thorlabs MFF usb serial device). To test virtually:

Create virtual serial port in terminal 1

socat -d -d pty,raw,echo=0 pty,raw,echo=0

Returns:

2024/05/13 09:06:37 socat[14186] N PTY is /dev/pts/9
2024/05/13 09:06:37 socat[14186] N PTY is /dev/pts/10
2024/05/13 09:06:37 socat[14186] N starting data transfer loop with FDs [5,5] and [7,7]

Connect controller in terminal 2

test-demo # port="/dev/pts/10" - https://github.com/DiamondLightSource/demo-fast-cs/pull/11

Send serial device response in terminal 3

Test the position AttrR (can inspect via Phoebus screen) echo -e -n "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01" > /dev/pts/9 or echo -e -n "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02" > /dev/pts/9

Monitor port in terminal 4 (optional)

cat -v /dev/pts/9

Can see what the controller sends

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 50.00000% with 18 lines in your changes are missing coverage. Please review.

Project coverage is 43.91%. Comparing base (2c46785) to head (7eb9da1). Report is 2 commits behind head on main.

Files Patch % Lines
src/fastcs/connections/serial_connection.py 50.00% 18 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #34 +/- ## ========================================== + Coverage 43.47% 43.91% +0.44% ========================================== Files 18 20 +2 Lines 651 690 +39 ========================================== + Hits 283 303 +20 - Misses 368 387 +19 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

GDYendell commented 4 months ago

This is good now, but could you squash everything into one commit? Changing the dependency list and then changing it back again is still losing the history. I think the easiest way to do this (besides lazygit) is

git reset --soft ed95aec
git commit --amend --no-edit
marcelldls commented 4 months ago

This is good now, but could you squash everything into one commit? Changing the dependency list and then changing it back again is still losing the history. I think the easiest way to do this (besides lazygit) is

git reset --soft ed95aec
git commit --amend --no-edit

Im happy to do this - Although I would suggest the easiest way is "Squash and merge"

GDYendell commented 4 months ago

With squash and merge you don't get a merge commit. Or rather it turns your commit into a merge commit and puts it on top, so there is not visible merge in the graph.

marcelldls commented 4 months ago

As you wish. BTW the easy way IMO is git rebase main -i