From 61c7905a329d3e2ca3887c3372c04743c4bed9b0 Mon Sep 17 00:00:00 2001 From: Tau Date: Fri, 30 Aug 2019 19:04:39 -0400 Subject: [PATCH] board/vfd.c: Add stub emu for "VFD" LCD --- board/meson.build | 2 ++ board/vfd.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ board/vfd.h | 5 ++++ 3 files changed, 69 insertions(+) create mode 100644 board/vfd.c create mode 100644 board/vfd.h diff --git a/board/meson.build b/board/meson.build index fe079c6..83a8cff 100644 --- a/board/meson.build +++ b/board/meson.build @@ -30,5 +30,7 @@ board_lib = static_library( 'slider-cmd.h', 'slider-frame.c', 'slider-frame.h', + 'vfd.c', + 'vfd.h', ], ) diff --git a/board/vfd.c b/board/vfd.c new file mode 100644 index 0000000..620a1b8 --- /dev/null +++ b/board/vfd.c @@ -0,0 +1,62 @@ +/* This is some sort of LCD display found on various cabinets. It is driven + directly by amdaemon, and it has something to do with displaying the status + of electronic payments. + + Part number in schematics is "VFD GP1232A02A FUTABA". + + Little else about this board is known. Black-holing the RS232 comms that it + receives seems to be sufficient for the time being. */ + +#include + +#include +#include + +#include "board/vfd.h" + +#include "hook/iohook.h" + +#include "hooklib/uart.h" + +#include "util/dprintf.h" +#include "util/dump.h" + +static HRESULT vfd_handle_irp(struct irp *irp); + +static struct uart vfd_uart; +static uint8_t vfd_written[512]; +static uint8_t vfd_readable[512]; + +HRESULT vfd_hook_init(unsigned int port_no) +{ + uart_init(&vfd_uart, port_no); + vfd_uart.written.bytes = vfd_written; + vfd_uart.written.nbytes = sizeof(vfd_written); + vfd_uart.readable.bytes = vfd_readable; + vfd_uart.readable.nbytes = sizeof(vfd_readable); + + return iohook_push_handler(vfd_handle_irp); +} + +static HRESULT vfd_handle_irp(struct irp *irp) +{ + HRESULT hr; + + assert(irp != NULL); + + if (!uart_match_irp(&vfd_uart, irp)) { + return iohook_invoke_next(irp); + } + + hr = uart_handle_irp(&vfd_uart, irp); + + if (FAILED(hr) || irp->op != IRP_OP_WRITE) { + return hr; + } + + dprintf("VFD TX:\n"); + dump(vfd_uart.written.bytes, vfd_uart.written.pos); + vfd_uart.written.pos = 0; + + return hr; +} diff --git a/board/vfd.h b/board/vfd.h new file mode 100644 index 0000000..01cd82e --- /dev/null +++ b/board/vfd.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +HRESULT vfd_hook_init(unsigned int port_no);