Repository navigation
Added parameters for logging server and command server ports - #62
Conversation
| "Available Commands:\n"); | ||
| " - TCP:" __XSTR__( | ||
| get_value(&pod->command_port)) "\n - STDIN\n\n" | ||
| "Available Commands:\n"); |
There was a problem hiding this comment.
__XSTR__ is meant to convert the value of a preprocessor macro to a string. i.e. if CMD_SVR_PORT is defined as 7779 then __XSTR__(CMD_SVR_PORT) will pre-process to "7779" and thus the preprocessed C will look like:
"...aspects of the pod\n" " - TCP:" "7779" "\n - STDIN\n\n" ...(The compiler will automatically concatenate the string literals into a single string)
Now... get_value(&pod->command_port) is not a preprocessor macro, and therefore is not known at compile time. Therefore you need to format the string at runtime using snprintf.
Conveniently, there is already an snprintf call wrapping this string to format in some other variables... although those variables are kindof messed up. This should read something like this:
int count =
snprintf(&outbuf[0], outbufc, "Pod CLI " POD_CLI_VERSION_STR ". Copyright " POD_COPY_YEAR
" " POD_COPY_OWNER "\n" POD_CREDITS
"This tool allows you to control various aspects of the pod\n"
" - TCP: %d\n - STDIN\n\n"
"Available Commands:\n", get_value(&pod->command_port)));There was a problem hiding this comment.
This will end up printing
...
- TCP: get_value(&pod->command_port)
...
EdHurtig
left a comment
There was a problem hiding this comment.
dropped in some comments on minor things
| #define MAX_PACKET_SIZE 1024 | ||
| #define LOG_SVR_NAME "controls.paradigmhyperloop.com" | ||
| #define LOG_SVR_PORT 7778 | ||
| #define LOG_SVR_NAME "pod-server.openloopalliance.com" |
There was a problem hiding this comment.
Mmmm seems we have a git merge error, this line should be reverted
| info("Connecting to logging server: " LOG_SVR_NAME); | ||
|
|
||
| int fd, portno = LOG_SVR_PORT; | ||
| pod_t *pod = get_pod(); |
There was a problem hiding this comment.
I'm curious if we are using different formatting commands
clang-format -style=llvm -i <file>
|
|
||
| note("Connected to " LOG_SVR_NAME ":" __XSTR__(LOG_SVR_PORT) " fd %d", fd); | ||
| note("Connected to " LOG_SVR_NAME | ||
| ":" __XSTR__(get_value(&pod->logging_port)) " fd %d", |
There was a problem hiding this comment.
Same as above, use %d to format in the log port at runtime
| int ch; | ||
|
|
||
| while ((ch = getopt(argc, argv, "rti:T:")) != -1) { | ||
| pod_t *pod = get_pod(); |
There was a problem hiding this comment.
parse_args() gets called before the pod structure is initialized. Can some fields get added to struct arguments to parse the args then those arguments get passed off to the pod_t following the init_pod() call in main()
|
Approved pending the |
|
Looks good to me! Please just revert the LOG_SVR_NAME git merge foo then mash that merge button |
Closes #61