rename base namespace and classes, completely remove old libsharperang (can get back from git history if necessary), remove unnecessary deps from UI test app
This commit is contained in:
parent
6c9b19ba91
commit
c22d5d753e
|
@ -3,13 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.29215.179
|
VisualStudioVersion = 16.0.29215.179
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sharperang", "sharperang\sharperang.csproj", "{677A8867-809E-4476-A9AE-7BEB5CE02F96}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "paperangapp", "sharperang\paperangapp.csproj", "{677A8867-809E-4476-A9AE-7BEB5CE02F96}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{A429CCEB-9331-4CD9-B3C0-A8F736732DEA} = {A429CCEB-9331-4CD9-B3C0-A8F736732DEA}
|
{A429CCEB-9331-4CD9-B3C0-A8F736732DEA} = {A429CCEB-9331-4CD9-B3C0-A8F736732DEA}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "libsharperang", "libsharperang\libsharperang.csproj", "{93203F87-29D0-4CDE-B2EE-156488E30186}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "libpaperang", "libpaperang\libpaperang.csproj", "{A429CCEB-9331-4CD9-B3C0-A8F736732DEA}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "libpaperang", "libpaperang\libpaperang.csproj", "{A429CCEB-9331-4CD9-B3C0-A8F736732DEA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "liblogtiny", "liblogtiny\liblogtiny.csproj", "{B7D242A8-F9DE-450B-9C87-5519CA782193}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "liblogtiny", "liblogtiny\liblogtiny.csproj", "{B7D242A8-F9DE-450B-9C87-5519CA782193}"
|
||||||
|
@ -24,10 +22,6 @@ Global
|
||||||
{677A8867-809E-4476-A9AE-7BEB5CE02F96}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{677A8867-809E-4476-A9AE-7BEB5CE02F96}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{677A8867-809E-4476-A9AE-7BEB5CE02F96}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{677A8867-809E-4476-A9AE-7BEB5CE02F96}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{677A8867-809E-4476-A9AE-7BEB5CE02F96}.Release|Any CPU.Build.0 = Release|Any CPU
|
{677A8867-809E-4476-A9AE-7BEB5CE02F96}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{93203F87-29D0-4CDE-B2EE-156488E30186}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{93203F87-29D0-4CDE-B2EE-156488E30186}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{93203F87-29D0-4CDE-B2EE-156488E30186}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{93203F87-29D0-4CDE-B2EE-156488E30186}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{A429CCEB-9331-4CD9-B3C0-A8F736732DEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{A429CCEB-9331-4CD9-B3C0-A8F736732DEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A429CCEB-9331-4CD9-B3C0-A8F736732DEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A429CCEB-9331-4CD9-B3C0-A8F736732DEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A429CCEB-9331-4CD9-B3C0-A8F736732DEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A429CCEB-9331-4CD9-B3C0-A8F736732DEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LibUsbDotNet" Version="2.2.29" />
|
<PackageReference Include="LibUsbDotNet" Version="2.2.29" />
|
||||||
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
|
<PackageReference Include="Microsoft.CSharp" Version="4.6.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
namespace libsharperang {
|
|
||||||
public abstract class Base {
|
|
||||||
public enum ConnectionType {
|
|
||||||
None,
|
|
||||||
UART,
|
|
||||||
USB,
|
|
||||||
Bluetooth
|
|
||||||
}
|
|
||||||
internal DataTransforms transform=new DataTransforms();
|
|
||||||
public string Model { get; internal set; }
|
|
||||||
public string FirmwareVer { get; internal set; }
|
|
||||||
public int Battery { get; internal set; }
|
|
||||||
public int ImageWidth { get; internal set; }
|
|
||||||
public ConnectionType ActiveConnectionType { get; internal set; } = ConnectionType.None;
|
|
||||||
internal bool InitialiseConnection() => false;
|
|
||||||
internal bool DestroyConnection() => false;
|
|
||||||
public Base() => InitialiseConnection();
|
|
||||||
~Base() => DestroyConnection();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace libsharperang {
|
|
||||||
public class CRC32 {
|
|
||||||
private uint _Initial = 0xFFFFFFFF;
|
|
||||||
public uint Initial { get => ~_Initial; private set => _Initial=~value; }
|
|
||||||
private uint Polynomial = 0xedb88320;
|
|
||||||
private uint[] Table;
|
|
||||||
public bool Initialised=false;
|
|
||||||
public CRC32(uint Initial) => this.Initial=Initial;
|
|
||||||
public CRC32() { }
|
|
||||||
public void Initialise() {
|
|
||||||
Table=Enumerable.Range(0, 256).Select(i => {
|
|
||||||
uint e=(uint)i;
|
|
||||||
for (ushort eb = 0; eb<8; ++eb) {
|
|
||||||
e=((e&1)!=0)
|
|
||||||
? (Polynomial^(e>>1))
|
|
||||||
: (e>>1);
|
|
||||||
}
|
|
||||||
return e;
|
|
||||||
}).ToArray();
|
|
||||||
Initialised=true;
|
|
||||||
}
|
|
||||||
public uint Reflect(uint iv) {
|
|
||||||
uint ivr=0;
|
|
||||||
for (int i = 0; i<32; i++) {
|
|
||||||
uint bit=(iv>>i)&1;
|
|
||||||
ivr |= (bit<<(31-i));
|
|
||||||
}
|
|
||||||
return ~ivr;
|
|
||||||
}
|
|
||||||
public uint GetChecksum<T>(IEnumerable<T> bytes) {
|
|
||||||
if (!Initialised) Initialise();
|
|
||||||
try {
|
|
||||||
return ~bytes.Aggregate(_Initial,
|
|
||||||
(csR, cB) => Table[(csR & 0xFF) ^ Convert.ToByte(cB)] ^ (csR>>8));
|
|
||||||
} catch (FormatException e) {
|
|
||||||
throw new Exception("Could not read stream as bytes", e);
|
|
||||||
} catch (InvalidCastException e) {
|
|
||||||
throw new Exception("Could not read stream as bytes", e);
|
|
||||||
} catch (OverflowException e) {
|
|
||||||
throw new Exception("Could not read stream as bytes", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace libsharperang {
|
|
||||||
public class DataTransforms {
|
|
||||||
public CRC32 hasher;
|
|
||||||
private uint MagicNumber=0x35769521;
|
|
||||||
public bool IsCrcInitialised() => (hasher!=null && hasher.Initialised);
|
|
||||||
public void InitialiseCrc(uint Key = 0x35769521) {
|
|
||||||
if (hasher==null || (hasher.Initialised && hasher.Initial != Key)) hasher=new CRC32(Key);
|
|
||||||
hasher.Initialise();
|
|
||||||
}
|
|
||||||
public byte[] GetHashSum(byte[] data) {
|
|
||||||
if (!IsCrcInitialised()) InitialiseCrc();
|
|
||||||
return BitConverter.GetBytes(hasher.GetChecksum(data));
|
|
||||||
}
|
|
||||||
public uint GetCrcKey() {
|
|
||||||
if (!IsCrcInitialised()) InitialiseCrc();
|
|
||||||
return hasher.Initial == MagicNumber ? hasher.Initial : hasher.Initial ^ MagicNumber;
|
|
||||||
}
|
|
||||||
public byte[] GetCrcKeyBytes() {
|
|
||||||
if (!IsCrcInitialised()) InitialiseCrc();
|
|
||||||
return BitConverter.GetBytes(GetCrcKey());
|
|
||||||
}
|
|
||||||
public byte[] GeneratePrintOpcode(byte[] data) => BitConverter.GetBytes(SwapEndianness(
|
|
||||||
0x00010000 | (((((
|
|
||||||
(uint)data.Length & 0xFFU) << 16) |
|
|
||||||
(uint)data.Length) & 0xFFFF00U) >> 8)));
|
|
||||||
public uint SwapEndianness(uint value) => (
|
|
||||||
(value & 0x000000FFU) << 24) |
|
|
||||||
((value & 0x0000FF00U) << 8) |
|
|
||||||
((value & 0x00FF0000U) >> 8) |
|
|
||||||
((value & 0xFF000000U) >> 24);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
using LibUsbDotNet;
|
|
||||||
|
|
||||||
namespace libsharperang {
|
|
||||||
interface IPrinter {
|
|
||||||
UsbDevice uDv { get; set; }
|
|
||||||
UsbEndpointWriter uWr { get; set; }
|
|
||||||
UsbEndpointReader uRd { get; set; }
|
|
||||||
bool Initialised();
|
|
||||||
bool WriteBytes(byte[]Frame);
|
|
||||||
byte[] ReadBytes();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="LibUsbDotNet" Version="2.2.29" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,204 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using LibUsbDotNet;
|
|
||||||
using LibUsbDotNet.Main;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* - 12 bytes is the minimum size of a payload, and 1018 bytes is the maximum
|
|
||||||
* - all frames sent to the printer follow the structure of:
|
|
||||||
* -- Frame.Begin (1 byte)
|
|
||||||
* -- PrinterCmd.* (4 bytes)
|
|
||||||
* -- Data (min. 2 bytes? max. 1008 bytes)
|
|
||||||
* -- CRC32 sum of the Data block (4 bytes)
|
|
||||||
* -- Frame.End (1 byte)
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace libsharperang {
|
|
||||||
public class Frame {
|
|
||||||
public DataTransforms transformer=new DataTransforms();
|
|
||||||
|
|
||||||
public enum Opcode {
|
|
||||||
SessionBegin = 10,
|
|
||||||
Feed,
|
|
||||||
PrintBegin = 20,
|
|
||||||
PrintContinue,
|
|
||||||
CrcTransmit = 30
|
|
||||||
}
|
|
||||||
private byte FrameStart = 0x02;
|
|
||||||
private byte FrameEnd = 0x03;
|
|
||||||
private byte[] ResolveOpcode(Opcode opcode) {
|
|
||||||
switch (opcode) {
|
|
||||||
case Opcode.SessionBegin: return new byte[] { 0x06, 0x00, 0x02, 0x00 };
|
|
||||||
case Opcode.Feed: return new byte[] { 0x1a, 0x00, 0x02, 0x00 };
|
|
||||||
case Opcode.CrcTransmit: return new byte[] { 0x18, 0x01, 0x04, 0x00 };
|
|
||||||
default: throw new NullReferenceException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public byte[] Build(Opcode opcode, byte[] data) => Build(ResolveOpcode(opcode), data, transformer);
|
|
||||||
public byte[] Build(byte[] opcode, byte[] data) => Build(opcode, data, transformer);
|
|
||||||
public byte[] Build(Opcode opcode, byte[] data, DataTransforms transformer) => Build(ResolveOpcode(opcode), data, transformer);
|
|
||||||
public byte[] Build(byte[] opcode, byte[] data, DataTransforms transformer) {
|
|
||||||
byte[] result=new byte[data.Length+10];
|
|
||||||
result[0]=FrameStart;
|
|
||||||
result[result.Length-1]=FrameEnd;
|
|
||||||
Buffer.BlockCopy(opcode, 0, result, 1, 4);
|
|
||||||
Buffer.BlockCopy(data, 0, result, 5, data.Length);
|
|
||||||
Buffer.BlockCopy(transformer.GetHashSum(data), 0, result, result.Length-5, 4);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public byte[] BuildTransmitCrc() {
|
|
||||||
if (!transformer.IsCrcInitialised()) transformer.InitialiseCrc(0x77c40d4d^0x35769521);
|
|
||||||
DataTransforms _=new DataTransforms();
|
|
||||||
_.InitialiseCrc();
|
|
||||||
return Build(Opcode.CrcTransmit, transformer.GetCrcKeyBytes(), _);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class USBPrinter : Base, IPrinter {
|
|
||||||
// TODO - work out if it's possible to get this working with the default usbprint.inf driver Windows uses on plugging in
|
|
||||||
// otherwise any user would have to first use Zadig to change the driver to WinUSB
|
|
||||||
private UsbDevice _uDv;
|
|
||||||
private UsbEndpointWriter _uWr;
|
|
||||||
private UsbEndpointReader _uRd;
|
|
||||||
UsbDevice IPrinter.uDv { get => _uDv; set { } }
|
|
||||||
UsbEndpointWriter IPrinter.uWr { get => _uWr; set { } }
|
|
||||||
UsbEndpointReader IPrinter.uRd { get => _uRd; set { } }
|
|
||||||
|
|
||||||
private ushort idVendor=0x4348;
|
|
||||||
private ushort idProduct=0x5584;
|
|
||||||
public Frame builder=new Frame();
|
|
||||||
public List<Guid> IDs;
|
|
||||||
public List<UsbRegistry> Devices;
|
|
||||||
|
|
||||||
public USBPrinter() {
|
|
||||||
ActiveConnectionType = ConnectionType.USB;
|
|
||||||
ImageWidth = 72;
|
|
||||||
}
|
|
||||||
public USBPrinter(int w) {
|
|
||||||
ActiveConnectionType = ConnectionType.USB;
|
|
||||||
ImageWidth = w;
|
|
||||||
}
|
|
||||||
~USBPrinter() {
|
|
||||||
Close();
|
|
||||||
ActiveConnectionType=ConnectionType.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialise() {
|
|
||||||
if (UsbDevice.AllDevices.Count == 0) throw new KeyNotFoundException("No WinUSB or LibUSB devices found");
|
|
||||||
Devices=(from d in UsbDevice.AllDevices
|
|
||||||
where d.Vid == idVendor && d.Pid == idProduct
|
|
||||||
select d)
|
|
||||||
.ToList<UsbRegistry>();
|
|
||||||
if (Devices.Count == 0) throw new KeyNotFoundException("No supported devices found!");
|
|
||||||
IDs=(from d in Devices
|
|
||||||
select d.DeviceInterfaceGuids[0])
|
|
||||||
.Distinct()
|
|
||||||
.ToList<Guid>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<int> GetAddressesFromGuid(Guid deviceId) => (from d in UsbDevice.AllDevices
|
|
||||||
where d.DeviceInterfaceGuids.Contains(deviceId)
|
|
||||||
select d.DeviceProperties
|
|
||||||
.Where(k => k.Key=="Address")
|
|
||||||
.FirstOrDefault().Value)
|
|
||||||
.ToList().ConvertAll(v => (int)v);
|
|
||||||
public string FoundPrinterGuids() => IDs?
|
|
||||||
.ConvertAll(p => p.ToString())
|
|
||||||
.Aggregate((a, b) => a+","+b);
|
|
||||||
public string FoundPrinterGuidAddrs(Guid deviceId) => GetAddressesFromGuid(deviceId)
|
|
||||||
.ConvertAll(a => a.ToString())
|
|
||||||
.Aggregate((a, b) => a+","+b);
|
|
||||||
public string FoundProdIds() => _uDv?.Info.ProductString;
|
|
||||||
public bool Open() {
|
|
||||||
return UsbDevice.AllDevices.Count == 0 ||
|
|
||||||
!IsPrinterPresent()
|
|
||||||
? false
|
|
||||||
: Open(IDs.FirstOrDefault());
|
|
||||||
}
|
|
||||||
public bool Open(Guid deviceId) => Open(deviceId,
|
|
||||||
GetAddressesFromGuid(deviceId).FirstOrDefault());
|
|
||||||
public bool Open(Guid deviceId, int deviceIndex) {
|
|
||||||
if (!IsPrinterPresent()) return false;
|
|
||||||
//first thought is to say "forgive me lord for i have sinned" but i am absolutely not repentant for this
|
|
||||||
bool OpenResult = (from d in UsbDevice.AllDevices
|
|
||||||
where d.DeviceInterfaceGuids.Contains(deviceId) &&
|
|
||||||
d.DeviceProperties.Where(k=>k.Key=="Address" && (int)k.Value==deviceIndex).Count() > 0
|
|
||||||
select d)
|
|
||||||
.FirstOrDefault()
|
|
||||||
.Open(out UsbDevice handle);
|
|
||||||
_uDv=handle;
|
|
||||||
return OpenResult;
|
|
||||||
}
|
|
||||||
public bool Claim() {
|
|
||||||
if (!IsPrinterPresent() ||
|
|
||||||
_uDv is null ||
|
|
||||||
!_uDv.IsOpen) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IUsbDevice p = _uDv as IUsbDevice;
|
|
||||||
p?.SetConfiguration(1);
|
|
||||||
p?.ClaimInterface(0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public void Close() {
|
|
||||||
_uWr?.Dispose();
|
|
||||||
_uRd?.Dispose();
|
|
||||||
IUsbDevice p=_uDv as IUsbDevice;
|
|
||||||
_=p?.ReleaseInterface(0);
|
|
||||||
_=p?.Close();
|
|
||||||
_uDv?.Close();
|
|
||||||
}
|
|
||||||
public void TransmitCrcKey() => WriteBytes(builder.BuildTransmitCrc());
|
|
||||||
public void StartSession() => StartSession(new byte[2] { 0, 0 });
|
|
||||||
public void StartSession(byte[] data) => WriteBytes(builder.Build(Frame.Opcode.SessionBegin, data));
|
|
||||||
public void InitPrinter() {
|
|
||||||
TransmitCrcKey();
|
|
||||||
NoOp();
|
|
||||||
PollPrinter();
|
|
||||||
}
|
|
||||||
public void PollPrinter() {
|
|
||||||
StartSession();
|
|
||||||
NoOp();
|
|
||||||
}
|
|
||||||
public void Feed() => Feed(100);
|
|
||||||
//Feed 0 is equivalent to a no-op, though on the P2 model it appears to engage the roller even though it doesn't ultimately result in any rotation
|
|
||||||
public void NoOp() => Feed(0);
|
|
||||||
public void Feed(int milliseconds) => WriteBytes(
|
|
||||||
builder.Build(Frame.Opcode.Feed, BitConverter.GetBytes(
|
|
||||||
transform.SwapEndianness(0x00000000 | (((((
|
|
||||||
(uint)milliseconds & 0xFFU) << 16) |
|
|
||||||
(uint)milliseconds) & 0xFFFF00U) >> 8))).Skip(2).ToArray()));
|
|
||||||
public void PrintBytes(byte[] data, bool autofeed=true) {
|
|
||||||
List<byte[]> datas = data
|
|
||||||
.Select((b, i) => new {Index = i, Value = b })
|
|
||||||
.GroupBy(b => b.Index/1008)
|
|
||||||
.Select(b => b.Select(bb => bb.Value).ToArray())
|
|
||||||
.ToList();
|
|
||||||
datas.ForEach(b => WriteBytes(builder.Build(transform.GeneratePrintOpcode(b), b)));
|
|
||||||
if (autofeed) Feed(200);
|
|
||||||
}
|
|
||||||
public bool IsPrinterPresent() => (Devices != null && Devices.Count > 0);
|
|
||||||
bool IPrinter.Initialised() => Initialised();
|
|
||||||
byte[] IPrinter.ReadBytes() => ReadBytes();
|
|
||||||
bool IPrinter.WriteBytes(byte[] Frame) => WriteBytes(Frame);
|
|
||||||
public bool Initialised() => (_uDv!=null);
|
|
||||||
public byte[] ReadBytes() {
|
|
||||||
if (_uRd==null) _uRd=_uDv?.OpenEndpointReader(ReadEndpointID.Ep01);
|
|
||||||
byte[] bRead=new byte[1024];
|
|
||||||
_=_uRd.Read(bRead, 100, out int _);
|
|
||||||
return bRead;
|
|
||||||
}
|
|
||||||
public bool WriteBytes(byte[] Frame) {
|
|
||||||
return WriteBytes(Frame, ImageWidth*3);
|
|
||||||
}
|
|
||||||
public bool WriteBytes(byte[] Frame, int milliseconds) {
|
|
||||||
if (_uWr==null) _uWr=_uDv?.OpenEndpointWriter(WriteEndpointID.Ep02);
|
|
||||||
bool result = _uWr.Write(Frame, 500, out int _) == ErrorCode.None;
|
|
||||||
Thread.Sleep(milliseconds);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Application x:Class="sharperang.App"
|
<Application x:Class="paperangapp.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="clr-namespace:sharperang"
|
xmlns:local="clr-namespace:paperangapp"
|
||||||
StartupUri="MainWindow.xaml">
|
StartupUri="MainWindow.xaml">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace sharperang {
|
namespace paperangapp {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for App.xaml
|
/// Interaction logic for App.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using liblogtiny;
|
using liblogtiny;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace sharperang {
|
namespace paperangapp {
|
||||||
class LUITextbox : ILogTiny, INotifyPropertyChanged {
|
class LUITextbox : ILogTiny, INotifyPropertyChanged {
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
protected void OnPropertyChanged(string propertyName) =>
|
protected void OnPropertyChanged(string propertyName) =>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<Window x:Class="sharperang.MainWindow"
|
<Window x:Class="paperangapp.MainWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:sharperang"
|
xmlns:local="clr-namespace:paperangapp"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="450" Width="800">
|
Title="MainWindow" Height="450" Width="800">
|
||||||
<Grid x:Name="gMain">
|
<Grid x:Name="gMain">
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
<ColumnDefinition Width="151*"/>
|
<ColumnDefinition Width="151*"/>
|
||||||
<ColumnDefinition Width="483*"/>
|
<ColumnDefinition Width="483*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<GroupBox Header="Paperang-Sharp Test Library" Margin="10,10,9.6,0" Grid.ColumnSpan="3" Height="217" VerticalAlignment="Top">
|
<GroupBox Header="libpaperang Library Tester" Margin="10,10,9.6,0" Grid.ColumnSpan="3" Height="217" VerticalAlignment="Top">
|
||||||
<Grid Margin="10,10,10,10">
|
<Grid Margin="10,10,10,10">
|
||||||
<Button x:Name="btClearLog" Content="Clear Log" HorizontalAlignment="Left" MinWidth="75" Margin="0,2,0,152.2" Click="BtClearLog_Click"/>
|
<Button x:Name="btClearLog" Content="Clear Log" HorizontalAlignment="Left" MinWidth="75" Margin="0,2,0,152.2" Click="BtClearLog_Click"/>
|
||||||
<Button x:Name="btInitUSB" Content="Initialise USB" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="75" Margin="0,23,0,0" IsDefault="True" Height="21" Click="BtInitUSB_Click"/>
|
<Button x:Name="btInitUSB" Content="Initialise USB" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="75" Margin="0,23,0,0" IsDefault="True" Height="21" Click="BtInitUSB_Click"/>
|
||||||
|
|
|
@ -9,7 +9,7 @@ using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace sharperang {
|
namespace paperangapp {
|
||||||
public partial class MainWindow : Window {
|
public partial class MainWindow : Window {
|
||||||
private ILogTiny logger;
|
private ILogTiny logger;
|
||||||
private BaseTypes.Connection mmjcx=BaseTypes.Connection.USB;
|
private BaseTypes.Connection mmjcx=BaseTypes.Connection.USB;
|
||||||
|
|
|
@ -5,11 +5,11 @@ using System.Windows;
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("sharperang")]
|
[assembly: AssemblyTitle("paperangapp")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("sharperang")]
|
[assembly: AssemblyProduct("paperangapp")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace sharperang.Properties
|
namespace paperangapp.Properties {
|
||||||
{
|
using System;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -19,51 +19,43 @@ namespace sharperang.Properties
|
||||||
// class via a tool like ResGen or Visual Studio.
|
// class via a tool like ResGen or Visual Studio.
|
||||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
// with the /str option, or rebuild your VS project.
|
// with the /str option, or rebuild your VS project.
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources
|
internal class Resources {
|
||||||
{
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
internal Resources()
|
internal Resources() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
{
|
get {
|
||||||
get
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
{
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("paperangapp.Properties.Resources", typeof(Resources).Assembly);
|
||||||
if ((resourceMan == null))
|
|
||||||
{
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("sharperang.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
/// resource lookups using this strongly typed resource class.
|
/// resource lookups using this strongly typed resource class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Globalization.CultureInfo Culture
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return resourceCulture;
|
return resourceCulture;
|
||||||
}
|
}
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
resourceCulture = value;
|
resourceCulture = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,21 +8,17 @@
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace sharperang.Properties
|
namespace paperangapp.Properties {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
{
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
public static Settings Default
|
public static Settings Default {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="LibUsbDotNet" version="2.2.29" targetFramework="net472" />
|
|
||||||
<package id="Microsoft.Win32.Registry" version="4.5.0" targetFramework="net472" />
|
|
||||||
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
|
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Collections.Specialized" version="4.3.0" targetFramework="net472" />
|
<package id="System.Collections.Specialized" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net472" />
|
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net472" />
|
<package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net472" />
|
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Diagnostics.TraceSource" version="4.3.0" targetFramework="net472" />
|
<package id="System.Diagnostics.TraceSource" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Drawing.Common" version="4.5.1" targetFramework="net472" />
|
<package id="System.Drawing.Common" version="4.6.0" targetFramework="net472" />
|
||||||
<package id="System.IO" version="4.3.0" targetFramework="net472" />
|
<package id="System.IO" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net472" />
|
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
|
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
|
||||||
|
@ -17,8 +15,8 @@
|
||||||
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net472" />
|
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net472" />
|
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net472" />
|
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Security.AccessControl" version="4.5.0" targetFramework="net472" />
|
<package id="System.Security.AccessControl" version="4.6.0" targetFramework="net472" />
|
||||||
<package id="System.Security.Principal.Windows" version="4.5.1" targetFramework="net472" />
|
<package id="System.Security.Principal.Windows" version="4.6.0" targetFramework="net472" />
|
||||||
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net472" />
|
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Threading" version="4.3.0" targetFramework="net472" />
|
<package id="System.Threading" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.Threading.Overlapped" version="4.3.0" targetFramework="net472" />
|
<package id="System.Threading.Overlapped" version="4.3.0" targetFramework="net472" />
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{677A8867-809E-4476-A9AE-7BEB5CE02F96}</ProjectGuid>
|
<ProjectGuid>{677A8867-809E-4476-A9AE-7BEB5CE02F96}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>sharperang</RootNamespace>
|
<RootNamespace>paperangapp</RootNamespace>
|
||||||
<AssemblyName>sharperang</AssemblyName>
|
<AssemblyName>paperangapp</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
@ -70,7 +71,7 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Drawing.Common.4.5.1\lib\net461\System.Drawing.Common.dll</HintPath>
|
<HintPath>..\packages\System.Drawing.Common.4.6.0\lib\net461\System.Drawing.Common.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
|
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
|
||||||
|
@ -107,11 +108,11 @@
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Security.AccessControl, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.Security.AccessControl, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll</HintPath>
|
<HintPath>..\packages\System.Security.AccessControl.4.6.0\lib\net461\System.Security.AccessControl.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Security.Principal.Windows, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.Security.Principal.Windows, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Security.Principal.Windows.4.5.1\lib\net461\System.Security.Principal.Windows.dll</HintPath>
|
<HintPath>..\packages\System.Security.Principal.Windows.4.6.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Threading.Overlapped, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.Threading.Overlapped, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Threading.Overlapped.4.3.0\lib\net46\System.Threading.Overlapped.dll</HintPath>
|
<HintPath>..\packages\System.Threading.Overlapped.4.3.0\lib\net46\System.Threading.Overlapped.dll</HintPath>
|
Loading…
Reference in New Issue