Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kestrel Collaboration
Kestrel Firmware
Zephyr Firmware
Commits
65f5a51d
Commit
65f5a51d
authored
3 years ago
by
Raptor Engineering Development Team
Browse files
Options
Download
Email Patches
Plain Diff
Add host status and command page to Web portal
parent
a49f5fbf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
3 deletions
+119
-3
embeddedfiles/header.inc
embeddedfiles/header.inc
+2
-1
kestrel/src/kestrel.h
kestrel/src/kestrel.h
+4
-0
kestrel/src/webportal.c
kestrel/src/webportal.c
+113
-2
No files found.
embeddedfiles/header.inc
View file @
65f5a51d
...
...
@@ -3,7 +3,8 @@
<div
class=
"sidebar_nav"
>
<a
href=
"/info"
>
Info
</a>
<a
href=
"/firmwareupload"
>
Firmware
</a>
<a
href=
"/firmware"
>
Firmware
</a>
<a
href=
"/hoststatus"
>
Status
</a>
</div>
<div
class=
"header"
>
...
...
This diff is collapsed.
Click to expand it.
kestrel/src/kestrel.h
View file @
65f5a51d
...
...
@@ -33,6 +33,10 @@
#define HOST_POWER_STATUS_RUNNING 2
#define HOST_POWER_STATUS_POWERING_OFF 3
#define KESTREL_VERSION_MAJOR 0
#define KESTREL_VERSION_MINOR 1
#define KESTREL_VERSION_PATCHLEVEL 0
struct
firmware_buffer_region
{
uint8_t
*
buffer_address
;
unsigned
long
long
buffer_length
;
...
...
This diff is collapsed.
Click to expand it.
kestrel/src/webportal.c
View file @
65f5a51d
...
...
@@ -13,6 +13,8 @@ LOG_MODULE_REGISTER(webportal, LOG_LEVEL_DBG);
#include "civetweb.h"
#include "simple_pwm.h"
#include "raptor_extensions.h"
#include "static_files.h"
...
...
@@ -141,6 +143,7 @@ int system_info_handler(struct mg_connection *conn, void *cbdata)
mg_printf
(
conn
,
"<li>Compiler - %s</li>
\n
"
,
info
.
compiler
);
mg_printf
(
conn
,
"<li>Board - %s</li>
\n
"
,
CONFIG_BOARD
);
mg_printf
(
conn
,
"<li>Architecture - %s</li>
\n
"
,
CONFIG_ARCH
);
mg_printf
(
conn
,
"<li>Version - %d.%d.%d</li>
\n
"
,
KESTREL_VERSION_MAJOR
,
KESTREL_VERSION_MINOR
,
KESTREL_VERSION_PATCHLEVEL
);
mg_printf
(
conn
,
"</ul>
\n
"
);
SEND_STANDARD_FOOTER
(
conn
);
...
...
@@ -148,6 +151,112 @@ int system_info_handler(struct mg_connection *conn, void *cbdata)
return
200
;
}
const
char
*
host_power_status_to_string
(
int
power_status
)
{
if
(
power_status
==
HOST_POWER_STATUS_OFFLINE
)
{
return
"Offline"
;
}
else
if
(
power_status
==
HOST_POWER_STATUS_POWERING_ON
)
{
return
"Powering On"
;
}
else
if
(
power_status
==
HOST_POWER_STATUS_RUNNING
)
{
return
"Online"
;
}
else
if
(
power_status
==
HOST_POWER_STATUS_POWERING_OFF
)
{
return
"Powering Off"
;
}
return
"Unknown"
;
}
int
host_status_handler
(
struct
mg_connection
*
conn
,
void
*
cbdata
)
{
int
i
;
uint8_t
pwm_values
[
4
]
=
{
0
,
0
,
0
,
0
};
int
tach_values
[
4
]
=
{
0
,
0
,
0
,
0
};
// Get status
#ifdef SIMPLEPWM_BASE
for
(
i
=
0
;
i
<
4
;
i
++
)
{
pwm_values
[
i
]
=
get_pwm_value
(
SIMPLEPWM_BASE
,
i
);
tach_values
[
i
]
=
get_tach_value
(
SIMPLEPWM_BASE
,
i
);
}
#endif
send_ok
(
conn
);
SEND_STANDARD_HEADER
(
conn
,
"Host Status"
)
mg_printf
(
conn
,
"<h3>Host status</h3>"
);
mg_printf
(
conn
,
"<p>"
);
mg_printf
(
conn
,
"<b>Synoptic</b><br>"
);
mg_printf
(
conn
,
"<div style=
\"
margin-left: 20px
\"
>"
);
mg_printf
(
conn
,
"System - %s<br>"
,
host_power_status_to_string
(
host_power_status
));
mg_printf
(
conn
,
"</div>"
);
mg_printf
(
conn
,
"<p>"
);
mg_printf
(
conn
,
"<b>Mechanical</b><br>"
);
mg_printf
(
conn
,
"<div style=
\"
margin-left: 20px
\"
>"
);
for
(
i
=
0
;
i
<
4
;
i
++
)
{
mg_printf
(
conn
,
"PWM channel %d - %d%% (%d RPM)<br>
\n
"
,
i
,
(
pwm_values
[
i
]
*
100
)
/
256
,
tach_values
[
i
]);
}
mg_printf
(
conn
,
"</div>"
);
mg_printf
(
conn
,
"<p>"
);
mg_printf
(
conn
,
"<b>Control</b><br>"
);
mg_printf
(
conn
,
"<div style=
\"
margin-left: 20px
\"
>"
);
mg_printf
(
conn
,
"<a href=
\"
/powercontrol?command=poweron
\"
>Power on</a><br>"
);
mg_printf
(
conn
,
"<a href=
\"
/powercontrol?command=poweroff
\"
>Power off</a>"
);
mg_printf
(
conn
,
"</div>"
);
SEND_STANDARD_FOOTER
(
conn
);
return
200
;
}
int
power_control_handler
(
struct
mg_connection
*
conn
,
void
*
cbdata
)
{
char
command_buffer
[
128
];
// Parse input
const
struct
mg_request_info
*
req_info
=
mg_get_request_info
(
conn
);
mg_get_var
(
req_info
->
query_string
,
strlen
(
req_info
->
query_string
),
"command"
,
command_buffer
,
sizeof
(
command_buffer
));
command_buffer
[
sizeof
(
command_buffer
)
-
1
]
=
0
;
send_ok
(
conn
);
SEND_STANDARD_HEADER
(
conn
,
"Power control"
)
mg_printf
(
conn
,
"<h3>Command processing</h3>"
);
mg_printf
(
conn
,
"<p>"
);
if
(
strcmp
(
command_buffer
,
"poweron"
)
==
0
)
{
if
(
host_power_status
==
HOST_POWER_STATUS_OFFLINE
)
{
mg_printf
(
conn
,
"Powering on host"
);
power_on_host
();
}
else
{
mg_printf
(
conn
,
"Host already online"
);
}
}
else
if
(
strcmp
(
command_buffer
,
"poweroff"
)
==
0
)
{
if
(
host_power_status
==
HOST_POWER_STATUS_OFFLINE
)
{
mg_printf
(
conn
,
"Host already offline"
);
}
else
{
mg_printf
(
conn
,
"Powering off host"
);
power_off_chassis
();
}
}
else
{
mg_printf
(
conn
,
"Invalid command!"
);
}
mg_printf
(
conn
,
"<p>"
);
mg_printf
(
conn
,
"<a href=
\"
/hoststatus
\"
>Back to host status page</a>"
);
SEND_STANDARD_FOOTER
(
conn
);
return
200
;
}
int
firmware_upload_form_handler
(
struct
mg_connection
*
conn
,
void
*
cbdata
)
{
mg_printf
(
conn
,
...
...
@@ -292,9 +401,11 @@ void *web_portal_pthread(void *arg)
// Dynamic pages
mg_set_request_handler
(
ctx
,
"/info$"
,
system_info_handler
,
(
void
*
)
0
);
mg_set_request_handler
(
ctx
,
"/hoststatus$"
,
host_status_handler
,
(
void
*
)
0
);
mg_set_request_handler
(
ctx
,
"/powercontrol$"
,
power_control_handler
,
(
void
*
)
0
);
mg_set_request_handler
(
ctx
,
"/firmware
upload
$"
,
firmware_upload_form_handler
,
(
void
*
)
"/firmwareupload
.callback
"
);
mg_set_request_handler
(
ctx
,
"/firmwareupload
.callback
$"
,
firmware_upload_handler
,
(
void
*
)
0
);
mg_set_request_handler
(
ctx
,
"/firmware$"
,
firmware_upload_form_handler
,
(
void
*
)
"/firmware
.
upload"
);
mg_set_request_handler
(
ctx
,
"/firmware
.
upload$"
,
firmware_upload_handler
,
(
void
*
)
0
);
return
0
;
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment