Skip to content

Added parameters for logging server and command server ports - #62

Merged
shorstman merged 9 commits into
masterfrom
port-parameters
Nov 11, 2017
Merged

shorstman merged 9 commits into
masterfrom
port-parameters

Conversation

@shorstman

Copy link
Copy Markdown
Member

Closes #61

@shorstman
shorstman requested a review from EdHurtig November 10, 2017 21:30
Comment thread core/commands.c Outdated
"Available Commands:\n");
" - TCP:" __XSTR__(
get_value(&pod->command_port)) "\n - STDIN\n\n"
"Available Commands:\n");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

__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)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will end up printing

...
 - TCP: get_value(&pod->command_port)
...

@EdHurtig EdHurtig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dropped in some comments on minor things

Comment thread core/config.h Outdated
#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"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mmmm seems we have a git merge error, this line should be reverted

Comment thread core/logging.c
info("Connecting to logging server: " LOG_SVR_NAME);

int fd, portno = LOG_SVR_PORT;
pod_t *pod = get_pod();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm curious if we are using different formatting commands

clang-format -style=llvm -i <file>

Comment thread core/logging.c Outdated

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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as above, use %d to format in the log port at runtime

Comment thread core/main.c Outdated
int ch;

while ((ch = getopt(argc, argv, "rti:T:")) != -1) {
pod_t *pod = get_pod();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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()

@EdHurtig

Copy link
Copy Markdown
Member

Approved pending the parse_args() and __XSTR__ changes

@EdHurtig

Copy link
Copy Markdown
Member

Looks good to me! Please just revert the LOG_SVR_NAME git merge foo then mash that merge button

@shorstman
shorstman merged commit e205c6e into master Nov 11, 2017
@shorstman
shorstman deleted the port-parameters branch November 11, 2017 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants