Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a demo SunSpec server #25

Open
3 tasks
altendky opened this issue Jan 27, 2021 · 1 comment
Open
3 tasks

Create a demo SunSpec server #25

altendky opened this issue Jan 27, 2021 · 1 comment

Comments

@altendky
Copy link
Owner

altendky commented Jan 27, 2021

Long term it would be nifty to have a server that fully implements lots of features that the embedded system has... short term, let's focus on having something we can use with the application while we are playing with it. Maybe start with these features.

  • Some data points that fluctuate so a client can observe varying values
  • A CLI to launch the server
  • Ability to launch and stop the server from within the present basic gui

Without saying this is well organized, there is an existing fixture used with the test code that can act as an example of a static SunSpec server. I have not yet looked through to plan out what bits need to change or what this should look like overall.

@pytest.fixture(name="sunspec_server")
async def sunspec_server_fixture(
nursery: trio.Nursery,
) -> typing.AsyncIterator[SunSpecServerFixtureResult]:
model_summaries = [
ssst.sunspec.server.ModelSummary(id=1, length=66),
ssst.sunspec.server.ModelSummary(id=17, length=12),
ssst.sunspec.server.ModelSummary(id=103, length=50),
ssst.sunspec.server.ModelSummary(id=126, length=226),
]
server = ssst.sunspec.server.Server.build(model_summaries=model_summaries)
host = "127.0.0.1"
[listener] = await nursery.start(
functools.partial(
trio.serve_tcp,
server.tcp_server,
host=host,
port=0,
),
)
yield SunSpecServerFixtureResult(
host=host,
port=listener.socket.getsockname()[1],
server=server,
)

While we will also be adding a client to the GUI (see #26), various existing tools can be used to poke at this server as well since it will be a standard Modbus TCP server. There is the pymodbus REPL and the EPC Power SunSpec demo and presumably various other Modbus clients such as QModBus.

@altendky
Copy link
Owner Author

Does this actually belong in https:/altendky/sundog?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant