add default port fallback for vfd

This commit is contained in:
2024-08-23 17:20:05 +02:00
parent 54cbbffae9
commit e6794807a6
9 changed files with 16 additions and 11 deletions

View File

@ -50,7 +50,7 @@ HRESULT vfd_handle_create_char2(struct const_iobuf* reader, struct iobuf* writer
static bool utf_enabled;
HRESULT vfd_hook_init(struct vfd_config *cfg)
HRESULT vfd_hook_init(struct vfd_config *cfg, int default_port)
{
if (!cfg->enable){
return S_FALSE;
@ -58,8 +58,13 @@ HRESULT vfd_hook_init(struct vfd_config *cfg)
utf_enabled = cfg->utf_conversion;
dprintf("VFD: enabling (port=%d)\n", cfg->port);
uart_init(&vfd_uart, cfg->port);
int port = cfg->port;
if (port == 0){
port = default_port;
}
dprintf("VFD: enabling (port=%d)\n", port);
uart_init(&vfd_uart, port);
vfd_uart.written.bytes = vfd_written;
vfd_uart.written.nbytes = sizeof(vfd_written);
vfd_uart.readable.bytes = vfd_readable;

View File

@ -9,5 +9,5 @@ struct vfd_config {
};
HRESULT vfd_hook_init(struct vfd_config *cfg);
HRESULT vfd_hook_init(struct vfd_config *cfg, int default_port);