mirror of
https://github.com/thewesker/RASCSI.git
synced 2025-12-22 05:11:15 -05:00
Merge branch 'master' of https://github.com/akuker/RASCSI
This commit is contained in:
160
src/oled_monitor/rascsi_oled_monitor.py
Executable file
160
src/oled_monitor/rascsi_oled_monitor.py
Executable file
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# RaSCSI Updates:
|
||||
# Updates to output rascsi status to an OLED display
|
||||
# Copyright (C) 2020 Tony Kuker
|
||||
# Author: Tony Kuker
|
||||
# Developed for: https://www.amazon.com/MakerFocus-Display-SSD1306-3-3V-5V-Arduino/dp/B079BN2J8V
|
||||
#
|
||||
# All other code:
|
||||
# Copyright (c) 2017 Adafruit Industries
|
||||
# Author: Tony DiCola & James DeVito
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
import time
|
||||
import os
|
||||
import datetime
|
||||
|
||||
#import Adafruit_GPIO.SPI as SPI
|
||||
import Adafruit_SSD1306
|
||||
|
||||
from PIL import Image
|
||||
from PIL import ImageDraw
|
||||
from PIL import ImageFont
|
||||
|
||||
import subprocess
|
||||
|
||||
# How long to delay between each update
|
||||
delay_time_ms = 250
|
||||
|
||||
# Raspberry Pi pin configuration:
|
||||
RST = None # on the PiOLED this pin isnt used
|
||||
# Note the following are only used with SPI:
|
||||
DC = 23
|
||||
SPI_PORT = 0
|
||||
SPI_DEVICE = 0
|
||||
|
||||
# Beaglebone Black pin configuration:
|
||||
# RST = 'P9_12'
|
||||
# Note the following are only used with SPI:
|
||||
# DC = 'P9_15'
|
||||
# SPI_PORT = 1
|
||||
# SPI_DEVICE = 0
|
||||
|
||||
# 128x32 display with hardware I2C:
|
||||
disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST)
|
||||
|
||||
# 128x64 display with hardware I2C:
|
||||
# disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST)
|
||||
|
||||
# Note you can change the I2C address by passing an i2c_address parameter like:
|
||||
# disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_address=0x3C)
|
||||
|
||||
# Alternatively you can specify an explicit I2C bus number, for example
|
||||
# with the 128x32 display you would use:
|
||||
# disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, i2c_bus=2)
|
||||
|
||||
# 128x32 display with hardware SPI:
|
||||
# disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))
|
||||
|
||||
# 128x64 display with hardware SPI:
|
||||
# disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))
|
||||
|
||||
# Alternatively you can specify a software SPI implementation by providing
|
||||
# digital GPIO pin numbers for all the required display pins. For example
|
||||
# on a Raspberry Pi with the 128x32 display you might use:
|
||||
# disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, dc=DC, sclk=18, din=25, cs=22)
|
||||
|
||||
print "Running with the following display:"
|
||||
print disp
|
||||
print
|
||||
print "Will update the OLED display every " + str(delay_time_ms) + "ms (approximately)"
|
||||
|
||||
|
||||
# Initialize library.
|
||||
disp.begin()
|
||||
|
||||
# Clear display.
|
||||
disp.clear()
|
||||
disp.display()
|
||||
|
||||
# Create blank image for drawing.
|
||||
# Make sure to create image with mode '1' for 1-bit color.
|
||||
width = disp.width
|
||||
height = disp.height
|
||||
image = Image.new('1', (width, height))
|
||||
|
||||
# Get drawing object to draw on image.
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# Draw a black filled box to clear the image.
|
||||
draw.rectangle((0,0,width,height), outline=0, fill=0)
|
||||
|
||||
# Draw some shapes.
|
||||
# First define some constants to allow easy resizing of shapes.
|
||||
padding = -2
|
||||
top = padding
|
||||
bottom = height-padding
|
||||
# Move left to right keeping track of the current x position for drawing shapes.
|
||||
x = 0
|
||||
|
||||
|
||||
# Load default font.
|
||||
font = ImageFont.load_default()
|
||||
|
||||
# Alternatively load a TTF font. Make sure the .ttf font file is in the same directory as the python script!
|
||||
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
|
||||
# font = ImageFont.truetype('Minecraftia.ttf', 8)
|
||||
|
||||
while True:
|
||||
|
||||
# Draw a black filled box to clear the image.
|
||||
draw.rectangle((0,0,width,height), outline=0, fill=0)
|
||||
|
||||
cmd = "rasctl -l"
|
||||
rascsi_list = subprocess.check_output(cmd, shell=True)
|
||||
|
||||
y_pos = top
|
||||
# Draw all of the meaningful data to the 'image'
|
||||
#
|
||||
# Example rascstl -l output:
|
||||
# pi@rascsi:~ $ rasctl -l
|
||||
#
|
||||
# +----+----+------+-------------------------------------
|
||||
# | ID | UN | TYPE | DEVICE STATUS
|
||||
# +----+----+------+-------------------------------------
|
||||
# | 1 | 0 | SCHD | /home/pi/harddisk.hda
|
||||
# | 6 | 0 | SCCD | NO MEDIA
|
||||
# +----+----+------+-------------------------------------
|
||||
# pi@rascsi:~ $
|
||||
for line in rascsi_list.split('\n'):
|
||||
# Skip empty strings, divider lines and the header line...
|
||||
if (len(line) == 0) or line.startswith("+---") or line.startswith("| ID | UN"):
|
||||
continue
|
||||
fields = line.split('|')
|
||||
output = str.strip(fields[1]) + " " + str.strip(fields[3]) + " " + os.path.basename(str.strip(fields[4]))
|
||||
draw.text((x, y_pos), output, font=font, fill=255)
|
||||
y_pos = y_pos + 8
|
||||
# If there is still room on the screen, we'll display the time. If there's not room it will just be clipped
|
||||
draw.text((x, y_pos), datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"), font=font, fill=255)
|
||||
|
||||
# Display image.
|
||||
disp.image(image)
|
||||
disp.display()
|
||||
time.sleep(1/delay_time_ms)
|
||||
31
src/php/LICENSE
Normal file
31
src/php/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (C) 2001-2006 PI.(ytanaka@ipc-tokai.or.jp)
|
||||
Copyright (C) 2014-2020 GIMONS
|
||||
Copyright (c) 2020, akuker
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
5
src/php/add_device.php
Normal file
5
src/php/add_device.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>I guess I should add a device</h1>
|
||||
</body>
|
||||
</html>
|
||||
BIN
src/php/concept_wireframe.png
Normal file
BIN
src/php/concept_wireframe.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 161 KiB |
5
src/php/delete.php
Normal file
5
src/php/delete.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>I guess I should delete something</h1>
|
||||
</body>
|
||||
</html>
|
||||
5
src/php/eject.php
Normal file
5
src/php/eject.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>I guess I should eject something</h1>
|
||||
</body>
|
||||
</html>
|
||||
9
src/php/rascsi.html
Normal file
9
src/php/rascsi.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<HTML>
|
||||
<HEAD> <TITLE>RaSCSI Control Page</TITLE></HEAD>
|
||||
<FRAMESET ROWS="20px,*" BORDER=0>
|
||||
<FRAME SRC="status.php" NAME="rascsi_status">
|
||||
<FRAME SRC="rascsi.php" NAME="rascsi_control">
|
||||
<NOFRAMES>You must use a browser that can display frames
|
||||
to see this page. </NOFRAMES>
|
||||
</FRAMESET>
|
||||
</HTML>
|
||||
328
src/php/rascsi.php
Normal file
328
src/php/rascsi.php
Normal file
@@ -0,0 +1,328 @@
|
||||
|
||||
<!-- PHP source code for controlling the RaSCSI - 68kmla edition with a web interface. -->
|
||||
<!-- Copyright (c) 2020 akuker -->
|
||||
<!-- Distributed under the BSD-3 Clause License -->
|
||||
|
||||
<!-- Note: the origina rascsi-php project was under MIT license.-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<script>
|
||||
function compute(f) {
|
||||
if (confirm("Are you sure?"))
|
||||
alert("Yes");
|
||||
else
|
||||
alert("No");
|
||||
}
|
||||
|
||||
function eject_image(id,file){
|
||||
if(confirm("Not implemented yet.... would eject " + file + " from " + id))
|
||||
window.location = 'eject.php';
|
||||
}
|
||||
function insert_image(id,file){
|
||||
if(confirm("Not implemented yet.... would insert " + file + " into " + id))
|
||||
alert("OK");
|
||||
}
|
||||
function add_device(id){
|
||||
if(confirm("Not implemented yet.... would add device id: " + id))
|
||||
alert("OK");
|
||||
}
|
||||
function remove_device(id){
|
||||
if(confirm("Not implemented yet.... would remove device id: " + id))
|
||||
alert("OK");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function delete_file(f){
|
||||
if(confirm("Are you sure you want to delete "+f+"?"))
|
||||
alert("OK");
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>h1{
|
||||
color:white;
|
||||
font-size:20px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
background-color: black;
|
||||
}</style>
|
||||
<style>h2{
|
||||
color:black;
|
||||
font-size:16px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
background-color: white;
|
||||
margin: 0px;
|
||||
}</style>
|
||||
</style>
|
||||
<style>body{
|
||||
color:black;
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
background-color: white;
|
||||
}</style>
|
||||
<STYLE>A {text-decoration: none;} </STYLE>
|
||||
<style>table,tr,td {
|
||||
border: 1px solid black;
|
||||
border-collapse:collapse;
|
||||
margin: none;
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%" >
|
||||
<tr style="background-color: black;">
|
||||
<td style="background-color: black;"><a href=http://github.com/akuker/RASCSI><h1>RaSCSI - 68kmla Edition</h1></a></td>
|
||||
<td style="background-color: black;">
|
||||
<form action="/rascsi.php">
|
||||
<input type="submit" value="Refresh"/>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
echo "Debug timestamp:";
|
||||
$t=time();
|
||||
echo($t . "<br>");
|
||||
// parameter check
|
||||
if(isset($_GET['restart_rascsi_service'])){
|
||||
// Restart the RaSCSI service
|
||||
echo 'exec("sudo systemctl restart rascsi.service");';
|
||||
} else if(isset($_GET['stop_rascsi_service'])){
|
||||
// Stop the RaSCSI Service
|
||||
echo 'exec("sudo systemctl stop rascsi.service");';
|
||||
} else if(isset($_GET['reboot_rasbperry_pi'])){
|
||||
// Reboot the Raspberry Pi
|
||||
echo 'exec("sudo shutdown -r -t 0");';
|
||||
} else if(isset($_GET['shutdown_raspberry_pi'])){
|
||||
// Shut down the Raspberry Pi
|
||||
echo 'exec("sudo shutdown -s -t 0");';
|
||||
}
|
||||
|
||||
current_rascsi_config();
|
||||
|
||||
|
||||
|
||||
function current_rascsi_config() {
|
||||
$raw_output = shell_exec("/usr/local/bin/rasctl -l");
|
||||
$rasctl_lines = explode(PHP_EOL, $raw_output);
|
||||
|
||||
echo ' <br>';
|
||||
echo ' <h2>Current RaSCSI Configuration</h2>';
|
||||
echo ' <table border="black">';
|
||||
echo ' <tr>';
|
||||
echo ' <td><b>SCSI ID</b></td>';
|
||||
echo ' <td><b>Type</b></td>';
|
||||
echo ' <td><b>Image File</b></td>';
|
||||
echo ' <td><b>Actions</b></td>';
|
||||
echo ' </tr>';
|
||||
|
||||
foreach ($rasctl_lines as $current_line)
|
||||
{
|
||||
if(strlen($current_line) === 0){
|
||||
continue;
|
||||
}
|
||||
if(strpos($current_line, '+----') === 0){
|
||||
continue;
|
||||
|
||||
}
|
||||
if(strpos($current_line, '| ID | UN') === 0){
|
||||
continue;
|
||||
}
|
||||
$segments = explode("|", $current_line);
|
||||
|
||||
echo ' <tr>';
|
||||
echo ' <form>';
|
||||
echo ' <td>'.trim($segments[1]).'</td>';
|
||||
echo ' <td>'.trim($segments[3]).'</td>';
|
||||
echo ' <td>'.trim($segments[4]).'</td>';
|
||||
echo ' <td>';
|
||||
echo ' <input type="button" value="Eject" onClick="eject_image(\''.trim($segments[1]).'\',\''.trim($segments[4]).'\')"/>';
|
||||
echo ' <input type="button" value="Disconnect" onClick="remove_device('.trim($segments[1]).')"/>';
|
||||
echo ' </td>';
|
||||
echo ' </form>';
|
||||
echo ' </tr>';
|
||||
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
function get_all_files()
|
||||
{
|
||||
$raw_ls_output = shell_exec('ls --time-style="+\"%Y-%m-%d %H:%M:%S\"" -alh --quoting-style=c /home/pi/images/');
|
||||
return $raw_ls_output;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<br>
|
||||
<h2>Add New Device</h2>
|
||||
<form action=rascsi.php>
|
||||
<table style="border: none">
|
||||
<tr style="border: none">
|
||||
<td style="border: none">SCSI ID:</td>
|
||||
<td style="border: none">
|
||||
<select>
|
||||
<option value="0">0</option>
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7">7</option>
|
||||
</select>
|
||||
</td>
|
||||
<td style="border: none">Device:</td>
|
||||
<td style="border: none">
|
||||
<select>
|
||||
<option value="hard_disk">Hard Disk</option>
|
||||
<option value="cd_rom">CD-ROM</option>
|
||||
<option value="zip_drive" disabled>Zip Drive</option>
|
||||
<option value="ethernet_tap" disabled>Ethernet Tap</option>
|
||||
<option value="filesystem_bridge" disabled>Filesystem Bridge</option>
|
||||
</select>
|
||||
</td>
|
||||
<td style="border: none">File:</td>
|
||||
<td style="border: none">
|
||||
<select>
|
||||
<?php
|
||||
$all_files = get_all_files();
|
||||
foreach(explode(PHP_EOL, $all_files) as $this_file){
|
||||
if(strpos($current_line, 'total') === 0){
|
||||
continue;
|
||||
}
|
||||
$file_name = file_name_from_ls($this_file);
|
||||
if(strlen($file_name) === 0){
|
||||
continue;
|
||||
}
|
||||
// Ignore files that start with a .
|
||||
if(strpos($file_name, '.') === 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<option value="'.$file_name.'">'.$file_name.'</option>';
|
||||
}
|
||||
|
||||
function mod_date_from_ls($value){
|
||||
$ls_pieces = explode("\"", $value);
|
||||
return $ls_pieces[1];
|
||||
}
|
||||
function file_name_from_ls($value){
|
||||
$ls_pieces = explode("\"", $value);
|
||||
return $ls_pieces[3];
|
||||
}
|
||||
function file_size_from_ls($value){
|
||||
$ls_pieces = explode("\"", $value);
|
||||
$file_props = preg_split("/\s+/", $ls_pieces[0]);
|
||||
return $file_props[4];
|
||||
}
|
||||
function file_category_from_file_name($value){
|
||||
if(strpos($value,".iso") > 0){
|
||||
return "CD-ROM Image";
|
||||
}
|
||||
if(strpos($value,".hda") > 0){
|
||||
return "Hard Disk Image";
|
||||
}
|
||||
return "Unknown type: " . $value;
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td style="border: none">
|
||||
<INPUT type="submit" value="Add" onClick="add_device(1)"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
<form>
|
||||
<input type=button value="asdf" onClick="compute(this.form)"><br>
|
||||
</form>
|
||||
|
||||
<h2>Image File Management</h2>
|
||||
<table border="black">
|
||||
<tr>
|
||||
<td><b>Location</b></td>
|
||||
<td><b>Filename</b></td>
|
||||
<td><b>Size</b></td>
|
||||
<td><b>Type</b></td>
|
||||
<td><b>Date Modified</b></td>
|
||||
<td><b>Actions</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php
|
||||
// Generate the table with all of the file names in it.....
|
||||
$all_files = get_all_files();
|
||||
foreach(explode(PHP_EOL, $all_files) as $this_file){
|
||||
if(strpos($this_file, 'total') === 0){
|
||||
continue;
|
||||
}
|
||||
$file_name = file_name_from_ls($this_file);
|
||||
if(strlen($file_name) === 0){
|
||||
continue;
|
||||
}
|
||||
// Ignore file names that start with .
|
||||
if(strpos($file_name,".") === 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
echo '<tr>';
|
||||
echo ' <form>';
|
||||
echo ' <td>SD Card</td>';
|
||||
echo ' <td>'.$file_name.'</td>';
|
||||
echo ' <td>'.file_size_from_ls($this_file).'</td>';
|
||||
echo ' <td>'.file_category_from_file_name($file_name).'</td>';
|
||||
echo ' <td>'.mod_date_from_ls($this_file).'</td>';
|
||||
echo ' <td>';
|
||||
echo ' <input type="button" value="Delete" onClick="delete_file(\''.$file_name.'\')" data-arg1="'.$file_name.'"/>';
|
||||
echo ' <input type="button" value="Copy to RAM Disk" disabled/>';
|
||||
echo ' </td>';
|
||||
echo ' </form>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<h2>Upload New Image File</h2>
|
||||
<form>
|
||||
<table style="border: none">
|
||||
<tr style="border: none">
|
||||
<td style="border: none; vertical-align:top;">
|
||||
<input type="file" id="filename" name="fname"><br><br>
|
||||
</td>
|
||||
<td style="border: none; vertical-align:top;">
|
||||
<input type="submit" value="Upload">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<br>
|
||||
<h2>RaSCSI Service Status</h2>
|
||||
<form method="get" action="rascsi.php" id="service">
|
||||
<input type="submit" name="restart_rascsi_service" value="Restart RaSCSI service"/>
|
||||
<input type="submit" name="stop_rascsi_service" value="Stop RaSCSI service"/>
|
||||
</form>
|
||||
|
||||
<br>
|
||||
<h2>Raspberry Pi Operations</h2>
|
||||
<form id="pi stuff">
|
||||
<input type="submit" name="reboot_rasbperry_pi" value="Reboot Raspberry Pi"/>
|
||||
<input type="submit" name="shutdown_raspberry_pi" value="Shut Down Raspberry Pi"/>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
5
src/php/remove_device.php
Normal file
5
src/php/remove_device.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>I guess I should remove a device</h1>
|
||||
</body>
|
||||
</html>
|
||||
44
src/php/status.php
Normal file
44
src/php/status.php
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
<!-- Simple file for showing the status of the RaSCSI process. Intended to be loaded as a frame in a larger page -->
|
||||
<!-- Copyright (c) 2020 akuker -->
|
||||
<!-- Distributed under the BSD-3 Clause License -->
|
||||
|
||||
<!-- Note: the origina rascsi-php project was under MIT license.-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.onload = setupRefresh;
|
||||
|
||||
function setupRefresh() {
|
||||
setTimeout("refreshPage();", 30000); // milliseconds
|
||||
}
|
||||
function refreshPage() {
|
||||
window.location = location.href;
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
// Blatently copied from stack overflow:
|
||||
// https://stackoverflow.com/questions/53695187/php-function-that-shows-status-of-systemctl-service
|
||||
$output = shell_exec("systemctl is-active rascsi");
|
||||
if (trim($output) == "active") {
|
||||
$color='green';
|
||||
$text='Running';
|
||||
}
|
||||
else{
|
||||
$color='red';
|
||||
$text='Stopped';
|
||||
}
|
||||
|
||||
echo '<body style="background-color: '.$color.';">';
|
||||
echo '<table width="100%" height=100% style="position: absolute; top: 0; bottom: 0; left: 0; right: 0; background-color:'.$color.'">';
|
||||
echo '<tr style:"height: 100%">';
|
||||
echo '<td style="color: white; background-color: '.$color.'; text-align: center; vertical-align: center; font-family: Arial, Helvetica, sans-serif;">'.$text.' '.date("h:i:sa").'</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
12
src/raspberrypi/.gitignore
vendored
Normal file
12
src/raspberrypi/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
*.o
|
||||
*.bak
|
||||
*.HDA
|
||||
*.save
|
||||
*.cbp
|
||||
*.layout
|
||||
*.log
|
||||
rascsi
|
||||
scsimon
|
||||
rasctl
|
||||
sasidump
|
||||
rasdump
|
||||
@@ -1,7 +1,23 @@
|
||||
.DEFAULT_GOAL: all
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -DNDEBUG -O3 -Wall
|
||||
CXX = g++
|
||||
CXXFLAGS = -DNDEBUG -O3 -Wall
|
||||
|
||||
DEBUG ?= 0
|
||||
ifeq ($(DEBUG), 1)
|
||||
# Debug CFLAGS
|
||||
CFLAGS = -DDISK_LOG -O0 -g -Wall -DDEBUG
|
||||
CXXFLAGS = -DDISK_LOG -O0 -g -Wall -DDEBUG
|
||||
BUILD_TYPE = Debug
|
||||
else
|
||||
# Release CFLAGS
|
||||
CFLAGS ?= -O3 -Wall -Werror
|
||||
CXXFLAGS ?= -O3 -Wall -Werror
|
||||
BUILD_TYPE = Release
|
||||
endif
|
||||
|
||||
# If its not specified, build for STANDARD configuration
|
||||
CONNECT_TYPE ?= STANDARD
|
||||
|
||||
ifdef CONNECT_TYPE
|
||||
CFLAGS += -DCONNECT_TYPE_$(CONNECT_TYPE)
|
||||
@@ -12,8 +28,17 @@ RASCSI = rascsi
|
||||
RASCTL = rasctl
|
||||
RASDUMP = rasdump
|
||||
SASIDUMP = sasidump
|
||||
SCSIMON = scsimon
|
||||
|
||||
USR_LOCAL_BIN = /usr/local/bin
|
||||
MAN_PAGE_DIR = /usr/share/man/man1
|
||||
DOC_DIR = ../../doc
|
||||
|
||||
#BIN_ALL = $(RASCSI) $(RASCTL) $(RASDUMP) $(SASIDUMP) $(SCSIMON)
|
||||
# Temporarily remove the RASDUMP and RASDUMP tools, since they're not needed
|
||||
# for my specific use case. If you need them - add them back in!
|
||||
BIN_ALL = $(RASCSI) $(RASCTL)
|
||||
|
||||
BIN_ALL = $(RASCSI) $(RASCTL) $(RASDUMP) $(SASIDUMP)
|
||||
|
||||
SRC_RASCSI = \
|
||||
rascsi.cpp \
|
||||
@@ -46,12 +71,21 @@ OBJ_RASCSI := $(SRC_RASCSI:%.cpp=%.o)
|
||||
OBJ_RASCTL := $(SRC_RASCTL:%.cpp=%.o)
|
||||
OBJ_RASDUMP := $(SRC_RASDUMP:%.cpp=%.o)
|
||||
OBJ_SASIDUMP := $(SRC_SASIDUMP:%.cpp=%.o)
|
||||
OBJ_SCSIMON := $(SRC_SCSIMON:%.cpp=%.o)
|
||||
#OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP) $(OBJ_SCSIMON)
|
||||
OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP)
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
ALL: $(BIN_ALL)
|
||||
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
.PHONY: all ALL docs
|
||||
all: $(BIN_ALL) docs
|
||||
ALL: all
|
||||
|
||||
docs: $(DOC_DIR)/rascsi_man_page.txt $(DOC_DIR)/rasctl_man_page.txt
|
||||
|
||||
$(RASCSI): $(OBJ_RASCSI)
|
||||
$(CXX) -o $@ $(OBJ_RASCSI) -lpthread
|
||||
@@ -65,5 +99,26 @@ $(RASDUMP): $(OBJ_RASDUMP)
|
||||
$(SASIDUMP): $(OBJ_SASIDUMP)
|
||||
$(CXX) -o $@ $(OBJ_SASIDUMP)
|
||||
|
||||
$(SCSIMON): $(OBJ_SCSIMON)
|
||||
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_SCSIMON) -lpthread
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ_ALL) $(BIN_ALL)
|
||||
|
||||
run:
|
||||
sudo ./$(RASCSI) -ID1 /home/pi/HARDDISK2.hda -ID6 /home/pi/marathon.iso
|
||||
|
||||
install: $(MAN_PAGE_DIR)/rascsi.1 $(MAN_PAGE_DIR)/rasctl.1
|
||||
sudo cp $(RASCTL) $(USR_LOCAL_BIN)
|
||||
sudo cp $(RASCSI) $(USR_LOCAL_BIN)
|
||||
|
||||
$(MAN_PAGE_DIR)/%.1 : $(DOC_DIR)/%.1
|
||||
sudo cp $< $@
|
||||
|
||||
$(DOC_DIR)/%_man_page.txt : $(DOC_DIR)/%.1
|
||||
@echo "!! ------ THIS FILE IS AUTO_GENERATED! DO NOT MANUALLY UPDATE!!!" > $@
|
||||
@echo "!! ------ The native file is $(notdir $<). Re-run 'make docs' after updating\n\n" >> $@
|
||||
man -l $< | col -bx >> $@
|
||||
|
||||
.PHONY: Debug
|
||||
Debug: all
|
||||
|
||||
@@ -1894,7 +1894,7 @@ void CHostPath::Refresh()
|
||||
if (stat(S2U(szPath), &sb))
|
||||
#else
|
||||
if (f_stat(S2U(szPath), NULL) != FR_OK)
|
||||
#endif // BAREMETAL
|
||||
#endif // BAREMETAL
|
||||
break; // 利用可能パターンを発見
|
||||
}
|
||||
}
|
||||
@@ -1957,7 +1957,7 @@ void CHostPath::Refresh()
|
||||
// 日付時刻
|
||||
pFilename->SetEntryDate(fno.fdate);
|
||||
pFilename->SetEntryTime(fno.ftime);
|
||||
#endif // BAREMETAL
|
||||
#endif // BAREMETAL
|
||||
|
||||
// クラスタ番号設定
|
||||
pFilename->SetEntryCluster(0);
|
||||
@@ -2045,7 +2045,7 @@ void CHostPath::Backup()
|
||||
m_tBackupT = fno.ftime;
|
||||
}
|
||||
}
|
||||
#endif // BAREMETAL
|
||||
#endif // BAREMETAL
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -2613,9 +2613,8 @@ void CHostFiles::AddFilename()
|
||||
{
|
||||
ASSERT(this);
|
||||
ASSERT(strlen(m_szHostResult) + strlen((const char*)m_szHumanFilename) < FILEPATH_MAX);
|
||||
|
||||
/// @warning Unicode未対応。いずれUnicodeの世界に飮まれた時はここで変換を行なう → 済
|
||||
strcat(m_szHostResult, (const char*)m_szHumanFilename);
|
||||
strncat(m_szHostResult, (const char*)m_szHumanFilename, ARRAY_SIZE(m_szHumanFilename));
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@@ -2896,7 +2895,7 @@ BOOL CHostFcb::Open()
|
||||
{
|
||||
#ifndef BAREMETAL
|
||||
struct stat st;
|
||||
|
||||
|
||||
ASSERT(this);
|
||||
ASSERT(strlen(m_szFilename) > 0);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -920,6 +920,11 @@ public:
|
||||
// Other
|
||||
BUS::phase_t FASTCALL GetPhase() {return ctrl.phase;}
|
||||
// Get the phase
|
||||
#ifdef DISK_LOG
|
||||
// Function to get the current phase as a String.
|
||||
void FASTCALL GetPhaseStr(char *str);
|
||||
#endif
|
||||
|
||||
int FASTCALL GetID() {return ctrl.id;}
|
||||
// Get the ID
|
||||
void FASTCALL GetCTRL(ctrl_t *buffer);
|
||||
@@ -1138,4 +1143,6 @@ private:
|
||||
// Internal data
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // disk_h
|
||||
|
||||
@@ -101,14 +101,14 @@ char* dirname(char *path)
|
||||
dirtmp[1] = '\0';
|
||||
return dirtmp;
|
||||
}
|
||||
|
||||
|
||||
p = path + strlen(path) - 1;
|
||||
while( *p == '/' ) {
|
||||
if( p == path )
|
||||
return path;
|
||||
*p-- = '\0';
|
||||
}
|
||||
|
||||
|
||||
while( p >= path && *p != '/' ) {
|
||||
p--;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ char* basename(char *path)
|
||||
basetmp[1] = '\0';
|
||||
return basetmp;
|
||||
}
|
||||
|
||||
|
||||
p = path + strlen(path) - 1;
|
||||
while( *p == '/' ) {
|
||||
if( p == path ) {
|
||||
@@ -151,11 +151,11 @@ char* basename(char *path)
|
||||
}
|
||||
*p-- = '\0';
|
||||
}
|
||||
|
||||
|
||||
while( p >= path && *p != '/' ) {
|
||||
p--;
|
||||
}
|
||||
|
||||
|
||||
return p + 1;
|
||||
}
|
||||
#endif // BAREMETAL
|
||||
@@ -219,9 +219,9 @@ void FASTCALL Filepath::Make()
|
||||
m_szPath[0] = _T('\0');
|
||||
|
||||
// 合成
|
||||
strcat(m_szPath, m_szDir);
|
||||
strcat(m_szPath, m_szFile);
|
||||
strcat(m_szPath, m_szExt);
|
||||
strncat(m_szPath, m_szDir, ARRAY_SIZE(m_szPath) - strlen(m_szPath));
|
||||
strncat(m_szPath, m_szFile, ARRAY_SIZE(m_szPath) - strlen(m_szPath));
|
||||
strncat(m_szPath, m_szExt, ARRAY_SIZE(m_szPath) - strlen(m_szPath));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -343,4 +343,4 @@ char Filepath::ShortName[_MAX_FNAME + _MAX_DIR];
|
||||
// ファイル名+拡張子
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
TCHAR Filepath::FileExt[_MAX_FNAME + _MAX_DIR];
|
||||
TCHAR Filepath::FileExt[_MAX_FNAME + _MAX_DIR];
|
||||
|
||||
@@ -169,6 +169,7 @@ BOOL FASTCALL GPIOBUS::Init(mode_e mode)
|
||||
// Open /dev/mem
|
||||
fd = open("/dev/mem", O_RDWR | O_SYNC);
|
||||
if (fd == -1) {
|
||||
printf("Error: Unable to open /dev/mem. Are you running as root?\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -274,6 +275,7 @@ BOOL FASTCALL GPIOBUS::Init(mode_e mode)
|
||||
PinConfig(PIN_DTD, GPIO_OUTPUT);
|
||||
|
||||
// Set the ENABLE signal
|
||||
// This is used to show that the application is running
|
||||
PinSetSignal(PIN_ENB, ENB_OFF);
|
||||
PinConfig(PIN_ENB, GPIO_OUTPUT);
|
||||
|
||||
@@ -373,6 +375,7 @@ BOOL FASTCALL GPIOBUS::Init(mode_e mode)
|
||||
MakeTable();
|
||||
|
||||
// Finally, enable ENABLE
|
||||
// Show the user that this app is running
|
||||
SetControl(PIN_ENB, ENB_ON);
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -114,6 +114,8 @@
|
||||
#endif // NDEBUG
|
||||
#endif // ASSERT_DIAG
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/(sizeof(x[0])))
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// 基本型定義
|
||||
|
||||
@@ -78,7 +78,8 @@ void Banner(int argc, char* argv[])
|
||||
FPRT(stdout,"Copyright (C) 2016-2020 GIMONS\n");
|
||||
FPRT(stdout,"Connect type : %s\n", CONNECT_DESC);
|
||||
|
||||
if (argc > 1 && strcmp(argv[1], "-h") == 0) {
|
||||
if ((argc > 1 && strcmp(argv[1], "-h") == 0) ||
|
||||
(argc > 1 && strcmp(argv[1], "--help") == 0)){
|
||||
FPRT(stdout,"\n");
|
||||
FPRT(stdout,"Usage: %s [-IDn FILE] ...\n\n", argv[0]);
|
||||
FPRT(stdout," n is SCSI identification number(0-7).\n");
|
||||
@@ -153,7 +154,7 @@ BOOL Init()
|
||||
|
||||
// GPIOBUS creation
|
||||
bus = new GPIOBUS();
|
||||
|
||||
|
||||
// GPIO Initialization
|
||||
if (!bus->Init()) {
|
||||
return FALSE;
|
||||
@@ -206,7 +207,7 @@ void Cleanup()
|
||||
|
||||
// Cleanup the Bus
|
||||
bus->Cleanup();
|
||||
|
||||
|
||||
// Discard the GPIOBUS object
|
||||
delete bus;
|
||||
|
||||
@@ -306,7 +307,7 @@ void ListDevice(FILE *fp)
|
||||
FPRT(fp, "No device is installed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
FPRT(fp, "+----+----+------+-------------------------------------\n");
|
||||
}
|
||||
|
||||
@@ -580,7 +581,7 @@ BOOL ProcessCmd(FILE *fp, int id, int un, int cmd, int type, char *file)
|
||||
filepath.SetPath(file);
|
||||
|
||||
// Open the file
|
||||
if (pUnit->Open(filepath)) {
|
||||
if (!pUnit->Open(filepath)) {
|
||||
FPRT(fp, "Error : File open error [%s]\n", file);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -862,7 +863,7 @@ static void *MonThread(void *param)
|
||||
{
|
||||
struct sched_param schedparam;
|
||||
struct sockaddr_in client;
|
||||
socklen_t len;
|
||||
socklen_t len;
|
||||
int fd;
|
||||
FILE *fp;
|
||||
char buf[BUFSIZ];
|
||||
@@ -892,8 +893,8 @@ static void *MonThread(void *param)
|
||||
|
||||
while (1) {
|
||||
// Wait for connection
|
||||
memset(&client, 0, sizeof(client));
|
||||
len = sizeof(client);
|
||||
memset(&client, 0, sizeof(client));
|
||||
len = sizeof(client);
|
||||
fd = accept(monsocket, (struct sockaddr*)&client, &len);
|
||||
if (fd < 0) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user