Skip to content

Json web/RPC port arg#134

Open
mitchcapper wants to merge 2 commits into
webosbrew:mainfrom
mitchcapper:json_port_arg
Open

Json web/RPC port arg#134
mitchcapper wants to merge 2 commits into
webosbrew:mainfrom
mitchcapper:json_port_arg

Conversation

@mitchcapper

Copy link
Copy Markdown

Add option to specify the RPC port if it is not 8090.

Also minor logging improvements for read errors.

Comment thread src/service.c
ERR("Error! Connection timeout.");
res = hyperion_read();
if (res < 0) {
ERR("Error! Connection timeout our error code: %d errno: %s", res, strerror(errno));

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.

Did you mean or?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No. As I modified hyperion_read to return several different error codes rather than just one I was stating that our internal error code is X and the last system error was Y.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds configurability for the Hyperion JSON-RPC/web port (default 8090) and expands diagnostics around read failures, so the service can target non-default RPC setups while providing more actionable error information.

Changes:

  • Introduce web_port in settings, initialize it to 8090, and (de)serialize it to/from JSON config.
  • Add --web-port CLI option and use the configured port when calling set_hdr_state(...).
  • Refine hyperion_read() return codes and update connection-loop logging.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/settings.h Adds web_port to the settings struct.
src/settings.c Initializes web_port, loads it from JSON, and saves it to JSON.
src/main.c Adds --web-port CLI flag and wiring to settings.
src/service.c Uses settings->web_port instead of a fixed RPC port; improves read-error logging.
src/json_rpc_client.h Removes the fixed RPC_PORT define (port now configured elsewhere).
src/hyperion_client.c Adds distinct negative return codes for different read failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/settings.c
Comment on lines 98 to 101
jobject_set(target, j_cstr_to_buffer("address"), jstring_create(settings->address));
jobject_set(target, j_cstr_to_buffer("port"), jnumber_create_i32(settings->port));
jobject_set(target, j_cstr_to_buffer("web_port"), jnumber_create_i32(settings->web_port));
jobject_set(target, j_cstr_to_buffer("priority"), jnumber_create_i32(settings->priority));
Comment thread src/settings.c
Comment on lines +58 to +59
if ((value = jobject_get(source, j_cstr_to_buffer("web-port"))) && jis_number(value))
jnumber_get_i32(value, &settings->web_port);
Comment thread src/settings.c
Comment on lines 9 to 12
settings->address = strdup("");
settings->port = 19400;
settings->web_port = 8090;
settings->priority = 150;
Comment thread src/settings.h
Comment on lines 14 to 17
char* address;
int port;
int web_port;
int priority;
Comment thread src/main.c
Comment on lines 29 to 33
{ "height", required_argument, 0, 'y' },
{ "address", required_argument, 0, 'a' },
{ "port", required_argument, 0, 'p' },
{ "web-port", required_argument, 0, 'w' },
{ "unix-socket", no_argument, 0, 'l' },
Comment thread src/main.c
Comment on lines 61 to 64
printf(" -a, --address=ADDR IP address of Hyperion server\n");
printf(" -p, --port=PORT Port of Hyperion flatbuffers server (default 19400)\n");
printf(" -w, --web-port=PORT Port of Hyperion RPC/web server (default 8090)\n");
printf(" -l, --unix-socket Connect through unix socket\n");
Comment thread src/main.c
Comment on lines 86 to 90
int ret;

while ((opt = getopt_long(argc, argv, "x:y:a:p:f:b:u:q:c:lvnhdVGrst", long_options, &longindex)) != -1) {
while ((opt = getopt_long(argc, argv, "x:y:a:p:w:f:b:u:q:c:lvnhdVGrst", long_options, &longindex)) != -1) {
switch (opt) {
case 'x':
Comment thread src/main.c
Comment on lines +103 to +105
case 'w':
settings.web_port = atol(optarg);
break;
Comment thread src/hyperion_client.c
Comment on lines 51 to +55
int n = read(sockfd, headbuff, 4);
uint32_t messageSize = ((headbuff[0] << 24) & 0xFF000000) | ((headbuff[1] << 16) & 0x00FF0000) | ((headbuff[2] << 8) & 0x0000FF00) | ((headbuff[3]) & 0x000000FF);
if (n < 0 || messageSize >= sizeof(recvBuff))
return -1;
if (n < 0)
return -3;
if (messageSize >= sizeof(recvBuff))
Comment thread src/service.c
Comment on lines +40 to 44
res = hyperion_read();
if (res < 0) {
ERR("Error! Connection timeout our error code: %d errno: %s", res, strerror(errno));
break;
}
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.

3 participants