Compare commits
No commits in common. "8f54104f5cc266241d3a3c903c81bb81d06cddfc" and "8a4e851ec6ba1db7775bb23694692d30894a6b2d" have entirely different histories.
8f54104f5c
...
8a4e851ec6
5 changed files with 31 additions and 125 deletions
|
@ -1,13 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define("FIFO", "/tmp/mapid");
|
$f = fopen("/tmp/mapid.fifo", "w+");
|
||||||
|
|
||||||
|
|
||||||
if (!file_exists(FIFO))
|
|
||||||
die("<!DOCTYPE html>\n<meta charset=\"UTF-8\">\n<h3 style=\"color:red;\">Error: FIFO file “" . FIFO . "” does not exist!</h3><p>Is <tt>fifo_bridge.py</tt> running?</p>");
|
|
||||||
|
|
||||||
|
|
||||||
$f = fopen(FIFO, "w+");
|
|
||||||
|
|
||||||
switch ($_POST["cmd"]) {
|
switch ($_POST["cmd"]) {
|
||||||
case "getty":
|
case "getty":
|
||||||
|
|
|
@ -6,43 +6,37 @@ $Title = "MAPID-FIFO Web-UI";
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title><?=$Title?></title>
|
<title></title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1><?=$Title?></h1>
|
<h1><?=$Title?></h1>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<section>
|
<form action="command.php" method="POST">
|
||||||
<form action="command.php" method="POST">
|
<input type="hidden" name="cmd" value="getty">
|
||||||
<input type="hidden" name="cmd" value="getty">
|
<button type="submit">Getty</button>
|
||||||
<button type="submit">Getty</button>
|
</form>
|
||||||
</form>
|
<hr>
|
||||||
</section>
|
<form action="command.php" method="POST">
|
||||||
<section>
|
<input type="hidden" name="cmd" value="cls">
|
||||||
<form action="command.php" method="POST">
|
<button type="submit">Clear</button>
|
||||||
<input type="hidden" name="cmd" value="cls">
|
</form>
|
||||||
<button type="submit">Clear</button>
|
<hr>
|
||||||
</form>
|
<form action="command.php" method="POST">
|
||||||
</section>
|
<input type="hidden" name="cmd" value="line">
|
||||||
<section>
|
<select name="line" height="1">
|
||||||
<form action="command.php" method="POST">
|
<option value="1">1</option>
|
||||||
<input type="hidden" name="cmd" value="line">
|
<option value="2">2</option>
|
||||||
<select name="line" height="1">
|
</select>
|
||||||
<option value="1">1</option>
|
<button type="submit">Select line</button>
|
||||||
<option value="2">2</option>
|
</form>
|
||||||
</select>
|
<hr>
|
||||||
<button type="submit">Select line</button>
|
<form action="command.php" method="POST">
|
||||||
</form>
|
<input type="hidden" name="cmd" value="echo">
|
||||||
</section>
|
<input type="text" name="text">
|
||||||
<section>
|
<button type="submit">Output</button>
|
||||||
<form action="command.php" method="POST">
|
</form>
|
||||||
<input type="hidden" name="cmd" value="echo">
|
|
||||||
<input type="text" name="text" placeholder="Text">
|
|
||||||
<button type="submit">Output</button>
|
|
||||||
</form>
|
|
||||||
</section>
|
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
*, *:before, *:after {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font: 2em "Source Serif Pro", serif;
|
|
||||||
margin: 1em 0 2em;
|
|
||||||
padding: .5em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
|
||||||
width: 25em;
|
|
||||||
max-width: 100%;
|
|
||||||
padding: .5em;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
section {
|
|
||||||
margin: 0 0 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
input, select {
|
|
||||||
border-radius: 6px;
|
|
||||||
padding: 6px 14px;
|
|
||||||
|
|
||||||
/*background: #DFDEDF;*/
|
|
||||||
background: #efefef;
|
|
||||||
/*box-shadow: 0px 0.5px 1px rgba(0, 0, 0, 0.1), inset 0px 0.5px 0.5px rgba(255, 255, 255, 0.5), 0px 0px 0px 0.5px rgba(0, 0, 0, 0.12);*/
|
|
||||||
color: #6E6D70;
|
|
||||||
display: inline-block;
|
|
||||||
margin-right: .5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* https://getcssscan.com/css-buttons-examples */
|
|
||||||
button {
|
|
||||||
/*display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;*/
|
|
||||||
padding: 6px 14px;
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
|
|
||||||
border-radius: 6px;
|
|
||||||
border: none;
|
|
||||||
|
|
||||||
background: #6E6D70;
|
|
||||||
box-shadow: 0px 0.5px 1px rgba(0, 0, 0, 0.1), inset 0px 0.5px 0.5px rgba(255, 255, 255, 0.5), 0px 0px 0px 0.5px rgba(0, 0, 0, 0.12);
|
|
||||||
color: #DFDEDF;
|
|
||||||
user-select: none;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
touch-action: manipulation;
|
|
||||||
}
|
|
||||||
|
|
||||||
button:focus {
|
|
||||||
box-shadow: inset 0px 0.8px 0px -0.25px rgba(255, 255, 255, 0.2), 0px 0.5px 1px rgba(0, 0, 0, 0.1), 0px 0px 0px 3.5px rgba(58, 108, 217, 0.5);
|
|
||||||
outline: 0;
|
|
||||||
}
|
|
|
@ -4,10 +4,9 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import mapid
|
import mapid
|
||||||
from serial.serialutil import SerialException
|
|
||||||
|
|
||||||
|
|
||||||
FIFO = "/tmp/mapid"
|
FIFO = "/tmp/mapid.fifo"
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -20,7 +19,10 @@ def main():
|
||||||
os.mkfifo(FIFO)
|
os.mkfifo(FIFO)
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
print("Created FIFO " + FIFO, file=sys.stderr)
|
print("Created FIFO " + FIFO, file=sys.stderr)
|
||||||
|
# f = open(FIFO, "w")
|
||||||
|
# f.write("\n")
|
||||||
|
# f.close()
|
||||||
|
# print("Created FIFO " + FIFO, file=sys.stderr)
|
||||||
f = open(FIFO, "r")
|
f = open(FIFO, "r")
|
||||||
print("Opened FIFO for reading", file=sys.stderr)
|
print("Opened FIFO for reading", file=sys.stderr)
|
||||||
m.cls()
|
m.cls()
|
||||||
|
@ -37,9 +39,6 @@ def main():
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
keep_going = False
|
keep_going = False
|
||||||
print()
|
print()
|
||||||
except SerialException:
|
|
||||||
keep_going = False
|
|
||||||
print("Caught a SerialException. Exiting now...", file=sys.stderr)
|
|
||||||
|
|
||||||
os.remove(FIFO)
|
os.remove(FIFO)
|
||||||
print("Removed FIFO.", file=sys.stderr)
|
print("Removed FIFO.", file=sys.stderr)
|
||||||
|
|
24
mapid.py
24
mapid.py
|
@ -1,8 +1,3 @@
|
||||||
"""MAPID utility library.
|
|
||||||
|
|
||||||
This module contains an utility class to control MAPID/CP using pyserial.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import dotenv #
|
import dotenv #
|
||||||
|
@ -10,15 +5,8 @@ import serial
|
||||||
|
|
||||||
|
|
||||||
DOTENV_LOADED = False
|
DOTENV_LOADED = False
|
||||||
"""bool: Is .env loaded?
|
|
||||||
|
|
||||||
Prevents loading .env multiple times for speed.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def load_dotenv():
|
def load_dotenv():
|
||||||
"""Load .env file
|
|
||||||
"""
|
|
||||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||||
dotenv.load_dotenv(os.path.join(basedir, ".env"))
|
dotenv.load_dotenv(os.path.join(basedir, ".env"))
|
||||||
global DOTENV_LOADED
|
global DOTENV_LOADED
|
||||||
|
@ -26,12 +14,6 @@ def load_dotenv():
|
||||||
|
|
||||||
|
|
||||||
def get_serial_dev():
|
def get_serial_dev():
|
||||||
"""Get SERIAL_DEV setting from dotenv.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str: The device file.
|
|
||||||
|
|
||||||
"""
|
|
||||||
global DOTENV_LOADED
|
global DOTENV_LOADED
|
||||||
if not DOTENV_LOADED:
|
if not DOTENV_LOADED:
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
@ -39,12 +21,6 @@ def get_serial_dev():
|
||||||
|
|
||||||
|
|
||||||
def get_serial_speed():
|
def get_serial_speed():
|
||||||
"""Get SERIAL_SPEED setting from dotenv.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
int: Serial speed in baud.
|
|
||||||
|
|
||||||
"""
|
|
||||||
global DOTENV_LOADED
|
global DOTENV_LOADED
|
||||||
if not DOTENV_LOADED:
|
if not DOTENV_LOADED:
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
Loading…
Reference in a new issue