Intial commit with original files, docs and modified Linux source.
This commit is contained in:
Executable
+8
@@ -0,0 +1,8 @@
|
||||
|
||||
PROG = scrd
|
||||
|
||||
OBJS = $(PROG).o
|
||||
|
||||
include ../build/Makefile_hidprog.inc
|
||||
|
||||
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "../common/rawhid.h"
|
||||
#include "../common/rawhid_defs.h"
|
||||
|
||||
typedef unsigned char u_char;
|
||||
|
||||
int do_read(const char* fname)
|
||||
{
|
||||
u_char fbuf[8192];
|
||||
size_t n = 0;
|
||||
int err = 0;
|
||||
size_t remaining = 0;
|
||||
u_char hbuf[64];
|
||||
if ( !err ) {
|
||||
printf("scrd: sending read request: ");
|
||||
hbuf[0] = RQ_READ;
|
||||
if ( 64 != rawhid_send(0, hbuf, 64, 100) ) {
|
||||
err = 1;
|
||||
printf("failed\n");
|
||||
} else {
|
||||
printf("ok\n");
|
||||
}
|
||||
}
|
||||
if ( !err ) {
|
||||
printf("device: ");
|
||||
if ( 64 != rawhid_recv(0, hbuf, 64, 220) ) {
|
||||
err = 2;
|
||||
printf("failed to respond\n");
|
||||
}
|
||||
}
|
||||
if ( !err ) {
|
||||
if ( hbuf[0] != RC_OK ) {
|
||||
err = 3;
|
||||
printf("not ok\n");
|
||||
} else {
|
||||
n = (size_t)hbuf[2] << 8 | hbuf[1];
|
||||
remaining = n;
|
||||
printf("has %u bytes: ok\n", n);
|
||||
}
|
||||
}
|
||||
u_char* p = fbuf;
|
||||
while ( !err && remaining ) {
|
||||
if ( !err ) {
|
||||
printf("scrd: ");
|
||||
hbuf[0] = RC_READY;
|
||||
if ( 64 != rawhid_send(0, hbuf, 64, 100) ) {
|
||||
err = 4;
|
||||
printf("failed to send 'ready' response\n");
|
||||
} else {
|
||||
printf("ready\n");
|
||||
}
|
||||
}
|
||||
if ( !err ) {
|
||||
printf("device: ");
|
||||
if ( 64 != rawhid_recv(0, hbuf, 64, 2000) ) {
|
||||
err = 5;
|
||||
printf("failed to respond\n");
|
||||
}
|
||||
}
|
||||
if ( !err ) {
|
||||
size_t len = remaining > 64 ? 64 : remaining;
|
||||
memcpy(p, hbuf, len);
|
||||
remaining -= len;
|
||||
p += len;
|
||||
printf("sent %u bytes: ok\n", len);
|
||||
}
|
||||
if ( !err ) {
|
||||
printf("scrd: ");
|
||||
hbuf[0] = RC_OK;
|
||||
if ( 64 != rawhid_send(0, hbuf, 64, 100) ) {
|
||||
err = 6;
|
||||
printf("failed to send 'ok' response\n");
|
||||
} else {
|
||||
printf("ok\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !err ) {
|
||||
printf("scrd: ");
|
||||
hbuf[0] = RC_COMPLETED;
|
||||
if ( 64 != rawhid_send(0, hbuf, 64, 100) ) {
|
||||
err = 7;
|
||||
printf("failed to send 'complete' response\n");
|
||||
} else {
|
||||
printf("complete\n");
|
||||
}
|
||||
}
|
||||
if ( !err ) {
|
||||
printf("scrd: writing file: ");
|
||||
FILE* f = fopen(fname, "wb");
|
||||
if ( f ) {
|
||||
fputc('S', f);
|
||||
fputc('C', f);
|
||||
size_t n2 = fwrite(fbuf, 1, n, f);
|
||||
fclose(f);
|
||||
printf("%u bytes: ", n2 + 2);
|
||||
printf("ok\n");
|
||||
} else {
|
||||
err = 8;
|
||||
printf("failed\n");
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
printf("scrd v1.10\n");
|
||||
|
||||
if ( argc != 2 ) {
|
||||
fprintf(stderr, "usage: scrd <config_binary>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("scrd: looking for Soarer\'s Converter: ");
|
||||
int r = rawhid_open(1, SC_VID, SC_PID, SC_USAGE_PAGE, SC_USAGE);
|
||||
if (r <= 0) {
|
||||
printf("not found\n");
|
||||
return -1;
|
||||
}
|
||||
printf("found\n");
|
||||
|
||||
int err = do_read(argv[1]);
|
||||
|
||||
if ( err ) {
|
||||
//printf("\nerror %d\n", err);
|
||||
}
|
||||
rawhid_close(0);
|
||||
return 0;
|
||||
}
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scrd", "scrd.vcproj", "{262F101E-E54C-4DD7-A7BD-C5F07A7B0047}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{262F101E-E54C-4DD7-A7BD-C5F07A7B0047}.Debug.ActiveCfg = Debug|Win32
|
||||
{262F101E-E54C-4DD7-A7BD-C5F07A7B0047}.Debug.Build.0 = Debug|Win32
|
||||
{262F101E-E54C-4DD7-A7BD-C5F07A7B0047}.Release.ActiveCfg = Release|Win32
|
||||
{262F101E-E54C-4DD7-A7BD-C5F07A7B0047}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Executable
+147
@@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="scrd"
|
||||
ProjectGUID="{262F101E-E54C-4DD7-A7BD-C5F07A7B0047}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/scrd.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/scrd.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../bin"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="4"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/scrd.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="FALSE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\scrd.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="..\lib\rawhid.lib">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
Reference in New Issue
Block a user