Skip to content

Commit f22edf8

Browse files
committed
V2.1 - Includes improved writing and a diagnostics section to help you setup your Arduino
1 parent 9e771dc commit f22edf8

18 files changed

+1209
-175
lines changed

ArduinoFloppyReader/ArduinoFloppyReader/ArduinoFloppyReader.vcxproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<PrecompiledHeader>Use</PrecompiledHeader>
8888
<WarningLevel>Level3</WarningLevel>
8989
<Optimization>Disabled</Optimization>
90-
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
90+
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9191
<SDLCheck>false</SDLCheck>
9292
</ClCompile>
9393
<Link>
@@ -115,7 +115,7 @@
115115
<Optimization>MaxSpeed</Optimization>
116116
<FunctionLevelLinking>true</FunctionLevelLinking>
117117
<IntrinsicFunctions>true</IntrinsicFunctions>
118-
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
118+
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
119119
<SDLCheck>true</SDLCheck>
120120
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
121121
</ClCompile>
@@ -150,8 +150,14 @@
150150
<ClInclude Include="targetver.h" />
151151
</ItemGroup>
152152
<ItemGroup>
153-
<ClCompile Include="..\lib\ADFWriter.cpp" />
154-
<ClCompile Include="..\lib\ArduinoInterface.cpp" />
153+
<ClCompile Include="..\lib\ADFWriter.cpp">
154+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
155+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
156+
</ClCompile>
157+
<ClCompile Include="..\lib\ArduinoInterface.cpp">
158+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
159+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
160+
</ClCompile>
155161
<ClCompile Include="Main.cpp" />
156162
<ClCompile Include="stdafx.cpp">
157163
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>

ArduinoFloppyReader/ArduinoFloppyReader/ArduinoFloppyReader.vcxproj.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
4-
<LocalDebuggerCommandArguments>5 "C:\Users\djrob\Desktop\workbench.adf" WRITE VERIFY</LocalDebuggerCommandArguments>
4+
<LocalDebuggerCommandArguments>DIAGNOSTIC 5</LocalDebuggerCommandArguments>
55
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
66
</PropertyGroup>
77
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

ArduinoFloppyReader/ArduinoFloppyReader/Main.cpp

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ArduinoFloppyReader (and writer)
22
*
3-
* Copyright (C) 2017 Robert Smith (@RobSmithDev)
3+
* Copyright (C) 2017-2018 Robert Smith (@RobSmithDev)
44
* http://amiga.robsmithdev.co.uk
55
*
66
* This program is free software; you can redistribute it and/or
@@ -25,11 +25,13 @@
2525
#include "stdafx.h"
2626
#include <windows.h>
2727
#include "..\lib\ADFWriter.h"
28+
#include <conio.h>
2829

2930
using namespace ArduinoFloppyReader;
3031

3132
ADFWriter writer;
3233

34+
3335
// Read an ADF file and write it to disk
3436
void adf2Disk(wchar_t* argv[], bool verify) {
3537
printf("\nWrite disk from ADF mode\n\n");
@@ -58,7 +60,8 @@ void adf2Disk(wchar_t* argv[], bool verify) {
5860
case adfrCompletedWithErrors: printf("\rADF file written to disk but there were errors during verification "); break;
5961
case adfrAborted: printf("\rWriting ADF file to disk "); break;
6062
case adfrFileError: printf("\rError opening ADF file. "); break;
61-
case adfrDriveError: printf("\rError communicating with the Arduino interface. "); break;
63+
case adfrDriveError: printf("\rError communicating with the Arduino interface. ");
64+
printf("\n%s ", writer.getLastError().c_str()); break;
6265
case adfrDiskWriteProtected: printf("\rError, disk is write protected! "); break;
6366
}
6467
}
@@ -90,22 +93,53 @@ void disk2ADF(wchar_t* argv[]) {
9093
case adfrFileError: printf("\rError creating ADF file. "); break;
9194
case adfrFileIOError: printf("\rError writing to ADF file. "); break;
9295
case adfrCompletedWithErrors: printf("\rADF file created with partial success. "); break;
93-
case adfrDriveError: printf("\rError communicating with the Arduino interface. "); break;
96+
case adfrDriveError: printf("\rError communicating with the Arduino interface. ");
97+
printf("\n%s ", writer.getLastError().c_str()); break;
9498
}
9599
}
96100

101+
// Run the diagnostics module
102+
void runDiagnostics(int comPort) {
103+
printf("\rRunning diagnostics on COM port: %i\n",comPort);
104+
105+
writer.runDiagnostics(comPort, [](bool isError, const std::string message)->void {
106+
if (isError)
107+
printf("DIAGNOSTICS FAILED: %s\n",message.c_str());
108+
else
109+
printf("%s\n", message.c_str());
110+
}, [](bool isQuestion, const std::string question)->bool {
111+
if (isQuestion)
112+
printf("%s [Y/N]: ", question.c_str());
113+
else
114+
printf("%s [Enter/ESC]: ", question.c_str());
115+
116+
char c;
117+
do {
118+
c = _getch();
119+
c=toupper(c);
120+
} while ((c != 'Y') && (c != 'N') && (c != '\n') && (c != '\r') && (c != '\x1B'));
121+
printf("%c\n", c);
122+
123+
return (c == 'Y') || (c == '\n') || (c == '\r') || (c == '\x1B');
124+
});
125+
126+
writer.closeDevice();
127+
}
128+
97129
int wmain(int argc, wchar_t* argv[], wchar_t *envp[])
98130
{
99-
printf("Arduino Amiga ADF Floppy disk Reader/Writer, Copyright (C) 2017 Robert Smith\r\n");
131+
printf("Arduino Amiga ADF Floppy disk Reader/Writer, Copyright (C) 2017-2018 Robert Smith\r\n");
100132
printf("Full sourcecode and documentation at http://amiga.robsmithdev.co.uk\r\n");
101133
printf("This is free software licenced under the GNU General Public Licence V3\r\n\r\n");
102134

103135
if (argc < 3) {
104136
printf("Usage:\r\n\n");
105137
printf("To read a disk to an ADF file:\r\n");
106-
printf("ArduinoFloppyReader COMPORT OutputFilename.ADF [READ]\r\n\r\n");
138+
printf("ArduinoFloppyReader <COMPORT> OutputFilename.ADF [READ]\r\n\r\n");
107139
printf("To write an ADF file to disk:\r\n");
108-
printf("ArduinoFloppyReader COMPORT InputFilename.ADF WRITE [VERIFY]\r\n\r\n");
140+
printf("ArduinoFloppyReader <COMPORT> InputFilename.ADF WRITE [VERIFY]\r\n\r\n");
141+
printf("To start interface diagnostics:\r\n");
142+
printf("ArduinoFloppyReader DIAGNOSTIC <COMPORT>\r\n\r\n");
109143
return 0;
110144
}
111145

@@ -120,12 +154,22 @@ int wmain(int argc, wchar_t* argv[], wchar_t *envp[])
120154
verify = wcscmp(argv[4], L"VERIFY") == 0;
121155
}
122156

123-
writer.openDevice(_wtoi(argv[1]));
157+
_wcsupr(argv[1]);
158+
if (wcscmp(argv[1], L"DIAGNOSTIC") == 0) {
159+
runDiagnostics(_wtoi(argv[2]));
160+
}
161+
else {
124162

125-
if (writeMode) adf2Disk(argv,verify); else disk2ADF(argv);
163+
if (!writer.openDevice(_wtoi(argv[1]))) {
164+
printf("\rError opening COM port: %s ", writer.getLastError().c_str());
165+
}
166+
else {
126167

127-
writer.closeDevice();
168+
if (writeMode) adf2Disk(argv, verify); else disk2ADF(argv);
128169

170+
writer.closeDevice();
171+
}
172+
}
129173

130174
getchar();
131175
return 0;

ArduinoFloppyReader/ArduinoFloppyReader/stdafx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ArduinoFloppyReader (and writer)
22
*
3-
* Copyright (C) 2017 Robert Smith (@RobSmithDev)
3+
* Copyright (C) 2017-2018 Robert Smith (@RobSmithDev)
44
* http://amiga.robsmithdev.co.uk
55
*
66
* This library is free software; you can redistribute it and/or
Binary file not shown.

ArduinoFloppyReader/ArduinoFloppyReaderWin/ArduinoFloppyReaderWin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ArduinoFloppyReaderWin
22
*
3-
* Copyright (C) 2017 Robert Smith (@RobSmithDev)
3+
* Copyright (C) 2017-2018 Robert Smith (@RobSmithDev)
44
* http://amiga.robsmithdev.co.uk
55
*
66
* This program is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
2323

2424

2525
#include "stdafx.h"
26+
#include "afxwin.h"
2627
#include "ArduinoFloppyReaderWin.h"
2728
#include "ArduinoFloppyReaderWinDlg.h"
2829

ArduinoFloppyReader/ArduinoFloppyReaderWin/ArduinoFloppyReaderWin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ArduinoFloppyReaderWin
22
*
3-
* Copyright (C) 2017 Robert Smith (@RobSmithDev)
3+
* Copyright (C) 2017-2018 Robert Smith (@RobSmithDev)
44
* http://amiga.robsmithdev.co.uk
55
*
66
* This program is free software; you can redistribute it and/or
Binary file not shown.

ArduinoFloppyReader/ArduinoFloppyReaderWin/ArduinoFloppyReaderWin.vcxproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
<PrecompiledHeader>Use</PrecompiledHeader>
9191
<WarningLevel>Level3</WarningLevel>
9292
<Optimization>Disabled</Optimization>
93-
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
93+
<PreprocessorDefinitions>USING_MFC;WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9494
<SDLCheck>true</SDLCheck>
9595
</ClCompile>
9696
<Link>
@@ -137,7 +137,7 @@
137137
<Optimization>MaxSpeed</Optimization>
138138
<FunctionLevelLinking>true</FunctionLevelLinking>
139139
<IntrinsicFunctions>true</IntrinsicFunctions>
140-
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
140+
<PreprocessorDefinitions>USING_MFC;WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
141141
<SDLCheck>true</SDLCheck>
142142
</ClCompile>
143143
<Link>
@@ -196,8 +196,14 @@
196196
<ClInclude Include="targetver.h" />
197197
</ItemGroup>
198198
<ItemGroup>
199-
<ClCompile Include="..\lib\ADFWriter.cpp" />
200-
<ClCompile Include="..\lib\ArduinoInterface.cpp" />
199+
<ClCompile Include="..\lib\ADFWriter.cpp">
200+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
201+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
202+
</ClCompile>
203+
<ClCompile Include="..\lib\ArduinoInterface.cpp">
204+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
205+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
206+
</ClCompile>
201207
<ClCompile Include="ArduinoFloppyReaderWin.cpp" />
202208
<ClCompile Include="ArduinoFloppyReaderWinDlg.cpp" />
203209
<ClCompile Include="stdafx.cpp">

0 commit comments

Comments
 (0)