-
Notifications
You must be signed in to change notification settings - Fork 33
SerialServer: allow clients to be non-sequential #45
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
base: master
Are you sure you want to change the base?
SerialServer: allow clients to be non-sequential #45
Conversation
This commit adds a helper function to get a client structure based on the badge. The allows for clients to be numerical, but not sequential, and guarantees serial input will always align to the correct client on each build. A side-effect of this method is that the clients are switched to by typing the ESCAPE_CHAR + badge number. This limits the number of clients to single-digits, 0 -> 9. Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
|
From previous PR: "Decoding badge numbers into getchar client IDs isn't safe unless client ID value 0 is reserved, which this change doesn't appear to be doing. The simplest approach that I can think of is to allow a string to be assigned to each client in the connection configuration (or just take the name of the instance+interface) and then allocate the getchar client IDs based on a lexicographical order of all the clients. This should provide a stable ID assignment across builds, and still allow badges to be allocated internally (where it can be ensured that badge 0 isn't used)." This hasn't been addressed yet, but I will handle it properly. |
|
@kent-mcleod I think i've addressed the zero badge issue. I guess it was an issue before this PR, so if you want to recommend any other changes, I'll be happy to implement. I also updated the corresponding PR in camkes-vm to align each serial server connection. |
I don't expect that it was an issue before? The templates were generating badges >= 1 and then the init logic was assigning them to clients based on enumeration order rather than badge value. (Although, if you manually set the badge to 0 via the *_attributes setting in the camkes configuration, then you could get a client with a badge value of 0). |
|
I more meant that the |
|
Yeah, I just tested without these changes, and Green/Blue were the colors being used (not Red). And the colors used by the VMM and VMs were inverted, which could be a bit confusing. |
1c2157a to
a718047
Compare
A zero badge is technically an unbadged notification, which would allow the owner to distribute the capability. CAmkES makes sure the attributes aren't set to zero, but that meant that "Client 0" was unused. This commit initializes the putchar interfaces, and subtracts 1 from the badge to get a client ID. This adds a runtime check to ensure a badge of 0 cannot be used by the serial server. Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
a718047 to
a4b933b
Compare
This commit does two things. One, it uses CAmkES to automatically generate the function headers. Two, it adds a template with a WEAK version of the headers, since if an interface isn't connected, the headers will not generate. Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
a4b933b to
4353bdf
Compare
|
|
||
| #define ESCAPE_CHAR '@' | ||
| #define MAX_CLIENTS 12 | ||
| #define MAX_CLIENTS 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a note in the code here, what drives this limit? I think it would help to get the background for people new to the code. Increasing this is not trivially possible.
| } | ||
|
|
||
| static int active_client = 0; | ||
| static int active_client = -2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make -1 and -2 a dedicated define now, so this is a bit more transparent, what magic values exist.
This commit adds a helper function to get a client structure based on the badge. The allows for clients to be numerical, but not sequential, and guarantees serial input will always align to the correct client on each build.
A side-effect of this method is that the clients are switched to by typing the ESCAPE_CHAR + badge number. This limits the number of clients to single-digits, 0 -> 9.