-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fujinet-pc-merge
- Loading branch information
Showing
19 changed files
with
574 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
BasedOnStyle: LLVM | ||
ColumnLimit: 200 | ||
AllowShortBlocksOnASingleLine: true | ||
AlwaysBreakAfterReturnType: None | ||
IncludeBlocks: Preserve | ||
SortIncludes: false | ||
UseTab: Always | ||
IndentWidth: 4 | ||
TabWidth: 4 | ||
AccessModifierOffset: -4 | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BreakInheritanceList: AfterColon | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: true | ||
AfterControlStatement: true | ||
AfterEnum: true | ||
AfterFunction: true | ||
AfterNamespace: true | ||
AfterStruct: true | ||
AfterUnion: true | ||
AfterExternBlock: true | ||
BeforeCatch: false | ||
BeforeElse: true | ||
BeforeLambdaBody: false | ||
BeforeWhile: false | ||
SplitEmptyRecord: false | ||
SplitEmptyNamespace: false | ||
IndentPPDirectives: BeforeHash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,40 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env bash | ||
|
||
echo "Starting FujiNet" | ||
./fujinet "$@" | ||
rc=$? | ||
fn_pid=0 | ||
rc=75 | ||
|
||
function start_fujinet { | ||
./fujinet "$@" & | ||
fn_pid=$! | ||
} | ||
|
||
function kill_fujinet { | ||
kill -HUP $fn_pid | ||
} | ||
|
||
function check_restart { | ||
echo "" | ||
echo "Received signal to restart FujiNet" | ||
kill -HUP $fn_pid | ||
sleep 1 | ||
start_fujinet "$@" | ||
} | ||
|
||
trap check_restart SIGHUP SIGUSR1 SIGCONT | ||
trap kill_fujinet SIGINT SIGTERM SIGQUIT | ||
|
||
# from sysexits.h | ||
# #define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ | ||
while [ $rc -eq 75 ]; do | ||
echo "Restarting FujiNet" | ||
./fujinet "$@" | ||
rc=$? | ||
echo "Starting FujiNet" | ||
start_fujinet "$@" | ||
running=1 | ||
while [ ! -z "$running" ]; do | ||
sleep 1 | ||
running=$(ps -ef | grep " $fn_pid " | grep -Ev "grep") | ||
done | ||
|
||
echo "Fujinet Not running, waiting on process" | ||
wait $fn_pid | ||
rc=$? | ||
done | ||
|
||
echo "FujiNet ended with exit code $rc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# PowerShell Runner run-fujinet.ps1 | ||
Write-Host "Starting FujiNet" | ||
|
||
do { | ||
.\fujinet.exe $args[0] $args[1] $args[2] $args[3] $args[4] $args[5] $args[6] $args[7] | ||
|
||
if ($LASTEXITCODE -eq 75) { | ||
Write-Host "Restarting FujiNet" | ||
} | ||
} while ($LASTEXITCODE -eq 75) | ||
|
||
Write-Host "FujiNet ended with exit code $LASTEXITCODE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef LOG_H_COMPATIBILITY | ||
#define LOG_H_COMPATIBILITY | ||
|
||
#include <cstdarg> | ||
#include <cstdio> | ||
|
||
// This is to provide a compatibility with SP over SLIP code copied over from AppleWin project | ||
// and simply converts to vprintf | ||
|
||
inline void LogFileOutput(const char *format, ...) | ||
{ | ||
va_list args; | ||
va_start(args, format); | ||
vprintf(format, args); | ||
va_end(args); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,55 @@ | ||
#include <chrono> | ||
#ifdef BUILD_APPLE | ||
|
||
#ifdef SP_OVER_SLIP | ||
|
||
#include "Connection.h" | ||
#include <iostream> | ||
|
||
std::vector<uint8_t> Connection::wait_for_request() | ||
{ | ||
// Use a timeout so we can stop waiting for responses | ||
while (is_connected_) { | ||
std::unique_lock<std::mutex> lock(data_mutex_); | ||
if (data_cv_.wait_for(lock, std::chrono::milliseconds(100), [this]() { return !data_map_.empty(); })) { | ||
const auto it = data_map_.begin(); | ||
std::vector<uint8_t> request_data = it->second; | ||
data_map_.erase(it); | ||
|
||
return request_data; | ||
} | ||
} | ||
return std::vector<uint8_t>(); | ||
} | ||
|
||
void Connection::join() | ||
{ | ||
if (reading_thread_.joinable()) | ||
{ | ||
reading_thread_.join(); | ||
} | ||
} | ||
|
||
#endif // SP_OVER_SLIP | ||
|
||
#endif // BUILD_APPLE | ||
#ifdef BUILD_APPLE | ||
#ifdef SP_OVER_SLIP | ||
|
||
#include "Connection.h" | ||
#include <condition_variable> | ||
#include <cstdint> | ||
#include <mutex> | ||
#include <stdexcept> | ||
#include <vector> | ||
|
||
// This is called after AppleWin sends a request to a device, and is waiting for the response | ||
std::vector<uint8_t> Connection::wait_for_response(uint8_t request_id, std::chrono::seconds timeout) | ||
{ | ||
std::unique_lock<std::mutex> lock(data_mutex_); | ||
// mutex is unlocked as it goes into a wait, so then the inserting thread can | ||
// add to map, and this can then pick it up when notified, or timeout. | ||
if (!data_cv_.wait_for(lock, timeout, [this, request_id]() { return data_map_.count(request_id) > 0; })) | ||
{ | ||
throw std::runtime_error("Timeout waiting for response"); | ||
} | ||
std::vector<uint8_t> response_data = data_map_[request_id]; | ||
data_map_.erase(request_id); | ||
return response_data; | ||
} | ||
|
||
// This is used by devices that are waiting for requests from AppleWin. | ||
// The codebase is used both sides of the connection. | ||
std::vector<uint8_t> Connection::wait_for_request() | ||
{ | ||
// Use a timeout so we can stop waiting for responses | ||
while (is_connected_) | ||
{ | ||
std::unique_lock<std::mutex> lock(data_mutex_); | ||
if (data_cv_.wait_for(lock, std::chrono::milliseconds(100), [this]() { return !data_map_.empty(); })) | ||
{ | ||
const auto it = data_map_.begin(); | ||
std::vector<uint8_t> request_data = it->second; | ||
data_map_.erase(it); | ||
|
||
return request_data; | ||
} | ||
} | ||
return std::vector<uint8_t>(); | ||
} | ||
|
||
void Connection::join() | ||
{ | ||
if (reading_thread_.joinable()) | ||
{ | ||
reading_thread_.join(); | ||
} | ||
} | ||
|
||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.