Skip to content

feat!: Add server#15

Merged
mzaniolo merged 18 commits intomainfrom
mzaniolo/server
Apr 16, 2026
Merged

feat!: Add server#15
mzaniolo merged 18 commits intomainfrom
mzaniolo/server

Conversation

@mzaniolo
Copy link
Copy Markdown
Owner

@mzaniolo mzaniolo commented Feb 24, 2026

This PR adds a iec104 server. The api is still low level, requires knowing some details of the protocol and validating the input but I'll leave api improvements for another PR

Closes: #4

@mzaniolo
Copy link
Copy Markdown
Owner Author

@fluxlinkage, since you have been working with iec104 servers I would appreciate a feedback on this implementation, specially on the server interfaces and it's capabilities

@fluxlinkage
Copy link
Copy Markdown
Contributor

@fluxlinkage, since you have been working with iec104 servers I would appreciate a feedback on this implementation, specially on the server interfaces and it's capabilities

Sorry for my delayed reply due to Chinese New Year.
Glad to see a Rust IEC104 server!
There is one little problem. Some commands (e.g. global interrogation) need replys (only on the same connection). Currently, it seems that it is not possible to handle this within on_new_objects in ServerCallback.
My fork (https://github.com/fluxlinkage/iec104) used a workaround by let on_new_objects return response ASDUs and send them (if any) (fluxlinkage@2fc6a42). But this introduced another problem: a lot of ASDUs may be sent as responses to a single command (e.g. global interrogation), and the number may exceed k. So a send queue should be used to avoid error (fluxlinkage@b85656e).
For reference only.

@mzaniolo
Copy link
Copy Markdown
Owner Author

mzaniolo commented Apr 11, 2026

@fluxlinkage thanks for the feedback.
I added a queue on the handler to buffer the responses as you suggested. You can find it here. It's used to enqueue asdus and dequeue.
The ServerCallback was always meant to be a low level interface. Since it's called from the main loop you would ideally just do a simple handling of the asdu and send anything over a channel for a more complex logic. I also added the rtu_server. This one is a high level interface and does most of the heavy lifting. The rtu_server interfaces should be enough for most of the user but let me know if you feel that something is missing. The rtu_server also serves as an example of how someone can build a server using the ServerCallback interface.

I ran some tests on it but I would appreciate if someone else would try out and do some testing too

@fluxlinkage
Copy link
Copy Markdown
Contributor

Great work!!!

Copy link
Copy Markdown
Contributor

@fluxlinkage fluxlinkage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broadcast address compatibility for interrogations.

Comment thread src/rtu_server/output.rs Outdated
Comment thread src/rtu_server/output.rs Outdated
@mzaniolo mzaniolo merged commit e687f5d into main Apr 16, 2026
2 checks passed
@mzaniolo mzaniolo deleted the mzaniolo/server branch April 16, 2026 15:52
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

Successfully merging this pull request may close these issues.

The field positive in Asdu should be renamed to negative

2 participants