mirror of
				https://github.com/davidgiven/fluxengine.git
				synced 2025-10-31 11:17:01 -07:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | e833c27452 | ||
|  | 717ab9a525 | 
| @@ -11,9 +11,12 @@ | ||||
| #include "lib/logger.h" | ||||
| #include "greaseweazle.h" | ||||
|  | ||||
| static USB* usb = NULL; | ||||
| static USB* usb = nullptr; | ||||
|  | ||||
| USB::~USB() {} | ||||
| USB::~USB() | ||||
| { | ||||
|     usb = nullptr; | ||||
| } | ||||
|  | ||||
| static std::shared_ptr<CandidateDevice> selectDevice() | ||||
| { | ||||
| @@ -59,8 +62,12 @@ static std::shared_ptr<CandidateDevice> selectDevice() | ||||
|     exit(1); | ||||
| } | ||||
|  | ||||
| USB* get_usb_impl() | ||||
| std::unique_ptr<USB> USB::create() | ||||
| { | ||||
|     std::unique_ptr<USB> r; | ||||
|     if (usb) | ||||
|         error("more than one USB object created"); | ||||
|  | ||||
|     /* Special case for certain configurations. */ | ||||
|  | ||||
|     if (globalConfig()->usb().has_greaseweazle() && | ||||
| @@ -68,33 +75,40 @@ USB* get_usb_impl() | ||||
|     { | ||||
|         const auto& conf = globalConfig()->usb().greaseweazle(); | ||||
|         log("Using Greaseweazle on serial port {}", conf.port()); | ||||
|         return createGreaseweazleUsb(conf.port(), conf); | ||||
|         r.reset(createGreaseweazleUsb(conf.port(), conf)); | ||||
|     } | ||||
|  | ||||
|     /* Otherwise, select a device by USB ID. */ | ||||
|  | ||||
|     auto candidate = selectDevice(); | ||||
|     switch (candidate->id) | ||||
|     else | ||||
|     { | ||||
|         case FLUXENGINE_ID: | ||||
|             log("Using FluxEngine {}", candidate->serial); | ||||
|             return createFluxengineUsb(candidate->device); | ||||
|         /* Otherwise, select a device by USB ID. */ | ||||
|  | ||||
|         case GREASEWEAZLE_ID: | ||||
|             log("Using Greaseweazle {} on {}", | ||||
|                 candidate->serial, | ||||
|                 candidate->serialPort); | ||||
|             return createGreaseweazleUsb( | ||||
|                 candidate->serialPort, globalConfig()->usb().greaseweazle()); | ||||
|         auto candidate = selectDevice(); | ||||
|         switch (candidate->id) | ||||
|         { | ||||
|             case FLUXENGINE_ID: | ||||
|                 log("Using FluxEngine {}", candidate->serial); | ||||
|                 r.reset(createFluxengineUsb(candidate->device)); | ||||
|                 break; | ||||
|  | ||||
|         default: | ||||
|             error("internal"); | ||||
|             case GREASEWEAZLE_ID: | ||||
|                 log("Using Greaseweazle {} on {}", | ||||
|                     candidate->serial, | ||||
|                     candidate->serialPort); | ||||
|                 r.reset(createGreaseweazleUsb(candidate->serialPort, | ||||
|                     globalConfig()->usb().greaseweazle())); | ||||
|                 break; | ||||
|  | ||||
|             default: | ||||
|                 error("internal"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     usb = r.get(); | ||||
|     return r; | ||||
| } | ||||
|  | ||||
| USB& getUsb() | ||||
| { | ||||
|     if (!usb) | ||||
|         usb = get_usb_impl(); | ||||
|         error("USB instance not created"); | ||||
|     return *usb; | ||||
| } | ||||
|   | ||||
| @@ -13,6 +13,9 @@ namespace libusbp | ||||
|  | ||||
| class USB | ||||
| { | ||||
| public: | ||||
|     static std::unique_ptr<USB> create(); | ||||
|  | ||||
| public: | ||||
|     virtual ~USB(); | ||||
|  | ||||
|   | ||||
| @@ -252,6 +252,7 @@ int mainAnalyseDriveResponse(int argc, const char* argv[]) | ||||
|     if (globalConfig()->flux_sink().type() != FLUXTYPE_DRIVE) | ||||
|         error("this only makes sense with a real disk drive"); | ||||
|  | ||||
|     auto usb = USB::create(); | ||||
|     usbSetDrive(globalConfig()->drive().drive(), | ||||
|         globalConfig()->drive().high_density(), | ||||
|         globalConfig()->drive().index_mode()); | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
| #include "lib/csvreader.h" | ||||
| #include "lib/image.h" | ||||
| #include "lib/decoders/fluxmapreader.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "agg2d.h" | ||||
| #include "stb_image_write.h" | ||||
| #include <math.h> | ||||
| @@ -228,6 +229,7 @@ static Image readCsv(const std::string& filename) | ||||
| int mainAnalyseLayout(int argc, const char* argv[]) | ||||
| { | ||||
|     flags.parseFlags(argc, argv); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|     Image image = readCsv(source.get()); | ||||
|     visualiseSectorsToFile(image, "out.svg"); | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
| #include "fluxengine.h" | ||||
| #include "lib/vfs/sectorinterface.h" | ||||
| #include "lib/vfs/vfs.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "src/fileutils.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -27,16 +28,10 @@ int mainFormat(int argc, const char* argv[]) | ||||
|         showProfiles("format", formats); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|         auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|         filesystem->create(quick, volumeName); | ||||
|         filesystem->flushChanges(); | ||||
|     } | ||||
|     catch (const FilesystemException& e) | ||||
|     { | ||||
|         error("{}", e.message); | ||||
|     } | ||||
|     auto usb = USB::create(); | ||||
|     auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|     filesystem->create(quick, volumeName); | ||||
|     filesystem->flushChanges(); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -12,6 +12,7 @@ | ||||
| #include "lib/vfs/sectorinterface.h" | ||||
| #include "lib/vfs/vfs.h" | ||||
| #include "lib/utils.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "src/fileutils.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -24,18 +25,12 @@ int mainGetDiskInfo(int argc, const char* argv[]) | ||||
|         showProfiles("getdiskinfo", formats); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|         auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|         auto attributes = filesystem->getMetadata(); | ||||
|     auto usb = USB::create(); | ||||
|     auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|     auto attributes = filesystem->getMetadata(); | ||||
|  | ||||
|         for (const auto& e : attributes) | ||||
|             fmt::print("{}={}\n", e.first, quote(e.second)); | ||||
|     } | ||||
|     catch (const FilesystemException& e) | ||||
|     { | ||||
|         error("{}", e.message); | ||||
|     } | ||||
|     for (const auto& e : attributes) | ||||
|         fmt::print("{}={}\n", e.first, quote(e.second)); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
| #include "fluxengine.h" | ||||
| #include "lib/vfs/sectorinterface.h" | ||||
| #include "lib/vfs/vfs.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "src/fileutils.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -26,24 +27,19 @@ int mainGetFile(int argc, const char* argv[]) | ||||
|         showProfiles("getfile", formats); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|         Path inputFilename(directory); | ||||
|         if (inputFilename.size() == 0) | ||||
|             error("you must supply a filename to read"); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|         std::string outputFilename = output; | ||||
|         if (outputFilename.empty()) | ||||
|             outputFilename = inputFilename.back(); | ||||
|     Path inputFilename(directory); | ||||
|     if (inputFilename.size() == 0) | ||||
|         error("you must supply a filename to read"); | ||||
|  | ||||
|         auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|         auto data = filesystem->getFile(inputFilename); | ||||
|         data.writeToFile(outputFilename); | ||||
|     } | ||||
|     catch (const FilesystemException& e) | ||||
|     { | ||||
|         error("{}", e.message); | ||||
|     } | ||||
|     std::string outputFilename = output; | ||||
|     if (outputFilename.empty()) | ||||
|         outputFilename = inputFilename.back(); | ||||
|  | ||||
|     auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|     auto data = filesystem->getFile(inputFilename); | ||||
|     data.writeToFile(outputFilename); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -12,6 +12,7 @@ | ||||
| #include "lib/vfs/sectorinterface.h" | ||||
| #include "lib/vfs/vfs.h" | ||||
| #include "lib/utils.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "src/fileutils.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -26,18 +27,13 @@ int mainGetFileInfo(int argc, const char* argv[]) | ||||
|         showProfiles("getfileinfo", formats); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|         auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|         auto dirent = filesystem->getDirent(Path(directory)); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|         for (const auto& e : dirent->attributes) | ||||
|             fmt::print("{}={}\n", e.first, quote(e.second)); | ||||
|     } | ||||
|     catch (const FilesystemException& e) | ||||
|     { | ||||
|         error("{}", e.message); | ||||
|     } | ||||
|     auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|     auto dirent = filesystem->getDirent(Path(directory)); | ||||
|  | ||||
|     for (const auto& e : dirent->attributes) | ||||
|         fmt::print("{}={}\n", e.first, quote(e.second)); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
| #include "lib/decoders/rawbits.h" | ||||
| #include "lib/sector.h" | ||||
| #include "lib/proto.h" | ||||
| #include "lib/usb/usb.h" | ||||
|  | ||||
| static FlagGroup flags; | ||||
|  | ||||
| @@ -133,6 +134,7 @@ int mainInspect(int argc, const char* argv[]) | ||||
| { | ||||
|     globalConfig().overrides()->mutable_flux_source()->set_type(FLUXTYPE_DRIVE); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, {}); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|     auto& fluxSource = globalConfig().getFluxSource(); | ||||
|     const auto fluxmap = fluxSource->readFlux(trackFlag, headFlag)->next(); | ||||
|   | ||||
							
								
								
									
										42
									
								
								src/fe-ls.cc
									
									
									
									
									
								
							
							
						
						
									
										42
									
								
								src/fe-ls.cc
									
									
									
									
									
								
							| @@ -11,6 +11,7 @@ | ||||
| #include "lib/vfs/sectorinterface.h" | ||||
| #include "lib/vfs/vfs.h" | ||||
| #include "lib/utils.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "src/fileutils.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -40,33 +41,28 @@ int mainLs(int argc, const char* argv[]) | ||||
|         showProfiles("ls", formats); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|         auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|         auto files = filesystem->list(Path(directory)); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|         int maxlen = 0; | ||||
|         for (const auto& dirent : files) | ||||
|             maxlen = std::max(maxlen, (int)quote(dirent->filename).size()); | ||||
|     auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|     auto files = filesystem->list(Path(directory)); | ||||
|  | ||||
|         uint32_t total = 0; | ||||
|         for (const auto& dirent : files) | ||||
|         { | ||||
|             fmt::print("{} {:{}}  {:6} {:4} {}\n", | ||||
|                 fileTypeChar(dirent->file_type), | ||||
|                 quote(dirent->filename), | ||||
|                 maxlen + 2, | ||||
|                 dirent->length, | ||||
|                 dirent->mode, | ||||
|                 dirent->attributes[Filesystem::CTIME]); | ||||
|             total += dirent->length; | ||||
|         } | ||||
|         fmt::print("({} files, {} bytes)\n", files.size(), total); | ||||
|     } | ||||
|     catch (const FilesystemException& e) | ||||
|     int maxlen = 0; | ||||
|     for (const auto& dirent : files) | ||||
|         maxlen = std::max(maxlen, (int)quote(dirent->filename).size()); | ||||
|  | ||||
|     uint32_t total = 0; | ||||
|     for (const auto& dirent : files) | ||||
|     { | ||||
|         error("{}", e.message); | ||||
|         fmt::print("{} {:{}}  {:6} {:4} {}\n", | ||||
|             fileTypeChar(dirent->file_type), | ||||
|             quote(dirent->filename), | ||||
|             maxlen + 2, | ||||
|             dirent->length, | ||||
|             dirent->mode, | ||||
|             dirent->attributes[Filesystem::CTIME]); | ||||
|         total += dirent->length; | ||||
|     } | ||||
|     fmt::print("({} files, {} bytes)\n", files.size(), total); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
| #include "fluxengine.h" | ||||
| #include "lib/vfs/vfs.h" | ||||
| #include "lib/utils.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "src/fileutils.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -18,21 +19,15 @@ int mainMkDir(int argc, const char* argv[]) | ||||
|         showProfiles("mkdir", formats); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|         auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|     auto usb = USB::create(); | ||||
|     auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|  | ||||
|         Path path(filename); | ||||
|         if (path.size() == 0) | ||||
|             error("filename missing"); | ||||
|     Path path(filename); | ||||
|     if (path.size() == 0) | ||||
|         error("filename missing"); | ||||
|  | ||||
|         filesystem->createDirectory(path); | ||||
|         filesystem->flushChanges(); | ||||
|     } | ||||
|     catch (const FilesystemException& e) | ||||
|     { | ||||
|         error("{}", e.message); | ||||
|     } | ||||
|     filesystem->createDirectory(path); | ||||
|     filesystem->flushChanges(); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
							
								
								
									
										27
									
								
								src/fe-mv.cc
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								src/fe-mv.cc
									
									
									
									
									
								
							| @@ -4,6 +4,7 @@ | ||||
| #include "fluxengine.h" | ||||
| #include "lib/vfs/vfs.h" | ||||
| #include "lib/utils.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "src/fileutils.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -19,25 +20,19 @@ int mainMv(int argc, const char* argv[]) | ||||
|         showProfiles("mv", formats); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|         auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|     auto usb = USB::create(); | ||||
|     auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|  | ||||
|         Path oldPath(oldFilename); | ||||
|         if (oldPath.size() == 0) | ||||
|             error("old filename missing"); | ||||
|     Path oldPath(oldFilename); | ||||
|     if (oldPath.size() == 0) | ||||
|         error("old filename missing"); | ||||
|  | ||||
|         Path newPath(newFilename); | ||||
|         if (newPath.size() == 0) | ||||
|             error("new filename missing"); | ||||
|     Path newPath(newFilename); | ||||
|     if (newPath.size() == 0) | ||||
|         error("new filename missing"); | ||||
|  | ||||
|         filesystem->moveFile(oldPath, newPath); | ||||
|         filesystem->flushChanges(); | ||||
|     } | ||||
|     catch (const FilesystemException& e) | ||||
|     { | ||||
|         error("{}", e.message); | ||||
|     } | ||||
|     filesystem->moveFile(oldPath, newPath); | ||||
|     filesystem->flushChanges(); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
| #include "fluxengine.h" | ||||
| #include "lib/vfs/sectorinterface.h" | ||||
| #include "lib/vfs/vfs.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "src/fileutils.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -26,25 +27,19 @@ int mainPutFile(int argc, const char* argv[]) | ||||
|         showProfiles("putfile", formats); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|         std::string inputFilename = input; | ||||
|         if (inputFilename.empty()) | ||||
|             error("you must supply a local file to read from"); | ||||
|     auto usb = USB::create(); | ||||
|     std::string inputFilename = input; | ||||
|     if (inputFilename.empty()) | ||||
|         error("you must supply a local file to read from"); | ||||
|  | ||||
|         Path outputFilename(path); | ||||
|         if (outputFilename.size() == 0) | ||||
|             error("you must supply a destination path to write to"); | ||||
|     Path outputFilename(path); | ||||
|     if (outputFilename.size() == 0) | ||||
|         error("you must supply a destination path to write to"); | ||||
|  | ||||
|         auto data = Bytes::readFromFile(inputFilename); | ||||
|         auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|         filesystem->putFile(outputFilename, data); | ||||
|         filesystem->flushChanges(); | ||||
|     } | ||||
|     catch (const FilesystemException& e) | ||||
|     { | ||||
|         error("{}", e.message); | ||||
|     } | ||||
|     auto data = Bytes::readFromFile(inputFilename); | ||||
|     auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|     filesystem->putFile(outputFilename, data); | ||||
|     filesystem->flushChanges(); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
| #include "lib/fluxsink/fluxsink.h" | ||||
| #include "lib/fluxsource/fluxsource.h" | ||||
| #include "lib/imagewriter/imagewriter.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "fluxengine.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -55,6 +56,7 @@ int mainRawRead(int argc, const char* argv[]) | ||||
|         showProfiles("rawread", formats); | ||||
|     globalConfig().overrides()->mutable_flux_source()->set_type(FLUXTYPE_DRIVE); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|     if (globalConfig()->flux_sink().type() == FLUXTYPE_DRIVE) | ||||
|         error("you can't use rawread to write to hardware"); | ||||
|   | ||||
| @@ -6,6 +6,7 @@ | ||||
| #include "lib/proto.h" | ||||
| #include "lib/fluxsource/fluxsource.h" | ||||
| #include "lib/fluxsink/fluxsink.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "fluxengine.h" | ||||
| #include <fstream> | ||||
| #include <ctype.h> | ||||
| @@ -61,6 +62,7 @@ int mainRawWrite(int argc, const char* argv[]) | ||||
|         showProfiles("rawwrite", formats); | ||||
|     globalConfig().overrides()->mutable_flux_sink()->set_type(FLUXTYPE_DRIVE); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|     if (globalConfig()->flux_source().type() == FLUXTYPE_DRIVE) | ||||
|         error("you can't use rawwrite to read from hardware"); | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
| #include "lib/fluxsource/fluxsource.h" | ||||
| #include "lib/fluxsink/fluxsink.h" | ||||
| #include "lib/imagewriter/imagewriter.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "fluxengine.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -60,6 +61,7 @@ int mainRead(int argc, const char* argv[]) | ||||
|         showProfiles("read", formats); | ||||
|     globalConfig().set("flux_source.type", "FLUXTYPE_DRIVE"); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|     if (globalConfig()->decoder().copy_flux_to().type() == FLUXTYPE_DRIVE) | ||||
|         error("you cannot copy flux to a hardware device"); | ||||
|   | ||||
							
								
								
									
										21
									
								
								src/fe-rm.cc
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/fe-rm.cc
									
									
									
									
									
								
							| @@ -4,6 +4,7 @@ | ||||
| #include "fluxengine.h" | ||||
| #include "lib/vfs/vfs.h" | ||||
| #include "lib/utils.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "src/fileutils.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -18,21 +19,15 @@ int mainRm(int argc, const char* argv[]) | ||||
|         showProfiles("rm", formats); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|         auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|     auto usb = USB::create(); | ||||
|     auto filesystem = Filesystem::createFilesystemFromConfig(); | ||||
|  | ||||
|         Path path(filename); | ||||
|         if (path.size() == 0) | ||||
|             error("filename missing"); | ||||
|     Path path(filename); | ||||
|     if (path.size() == 0) | ||||
|         error("filename missing"); | ||||
|  | ||||
|         filesystem->deleteFile(path); | ||||
|         filesystem->flushChanges(); | ||||
|     } | ||||
|     catch (const FilesystemException& e) | ||||
|     { | ||||
|         error("{}", e.message); | ||||
|     } | ||||
|     filesystem->deleteFile(path); | ||||
|     filesystem->flushChanges(); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -23,6 +23,7 @@ int mainRpm(int argc, const char* argv[]) | ||||
|     if (globalConfig()->flux_source().type() != FLUXTYPE_DRIVE) | ||||
|         error("this only makes sense with a real disk drive"); | ||||
|  | ||||
|     auto usb = USB::create(); | ||||
|     usbSetDrive(globalConfig()->drive().drive(), | ||||
|         false, | ||||
|         globalConfig()->drive().index_mode()); | ||||
|   | ||||
| @@ -26,6 +26,7 @@ int mainSeek(int argc, const char* argv[]) | ||||
|     if (globalConfig()->flux_source().type() != FLUXTYPE_DRIVE) | ||||
|         error("this only makes sense with a real disk drive"); | ||||
|  | ||||
|     auto usb = USB::create(); | ||||
|     usbSetDrive(globalConfig()->drive().drive(), | ||||
|         false, | ||||
|         globalConfig()->drive().index_mode()); | ||||
|   | ||||
| @@ -7,6 +7,7 @@ static FlagGroup flags; | ||||
| int mainTestBandwidth(int argc, const char* argv[]) | ||||
| { | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, {}); | ||||
|     auto usb = USB::create(); | ||||
|     usbTestBulkWrite(); | ||||
|     usbTestBulkRead(); | ||||
|     return 0; | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| #include "lib/globals.h" | ||||
| #include "lib/flags.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "lib/usb/usbfinder.h" | ||||
| #include <fmt/format.h> | ||||
|  | ||||
| @@ -8,6 +9,7 @@ static FlagGroup flags; | ||||
| int mainTestDevices(int argc, const char* argv[]) | ||||
| { | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, {}); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|     auto candidates = findUsbDevices(); | ||||
|     switch (candidates.size()) | ||||
|   | ||||
| @@ -15,6 +15,7 @@ static std::string display_voltages(struct voltages& v) | ||||
| int mainTestVoltages(int argc, const char* argv[]) | ||||
| { | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, {}); | ||||
|     auto usb = USB::create(); | ||||
|     struct voltages_frame f; | ||||
|     usbMeasureVoltages(&f); | ||||
|  | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
| #include "arch/brother/brother.h" | ||||
| #include "arch/ibm/ibm.h" | ||||
| #include "lib/imagereader/imagereader.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "fluxengine.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <fstream> | ||||
| @@ -66,6 +67,7 @@ int mainWrite(int argc, const char* argv[]) | ||||
|     globalConfig().setVerificationFluxSource("drive:0"); | ||||
|  | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|     auto usb = USB::create(); | ||||
|  | ||||
|     auto& reader = globalConfig().getImageReader(); | ||||
|     std::shared_ptr<Image> image = reader->readMappedImage(); | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
| #include "lib/imagereader/imagereader.h" | ||||
| #include "lib/imagewriter/imagewriter.h" | ||||
| #include "lib/layout.h" | ||||
| #include "lib/usb/usb.h" | ||||
| #include "texteditorwindow.h" | ||||
| #include "iconbutton.h" | ||||
| #include <wx/config.h> | ||||
| @@ -291,6 +292,11 @@ public: | ||||
|  | ||||
|         globalConfig().validateAndThrow(); | ||||
|         ClearLog(); | ||||
|  | ||||
|         /* Ensure the USB device is opened. */ | ||||
|  | ||||
|         _usb.reset(); | ||||
|         _usb = USB::create(); | ||||
|     } | ||||
|  | ||||
|     const wxBitmap GetBitmap() override | ||||
| @@ -809,6 +815,7 @@ private: | ||||
|     std::string _extraConfiguration; | ||||
|     std::set<std::pair<std::string, std::string>> _formatOptions; | ||||
|     int _currentlyDisplayedFormat = wxNOT_FOUND - 1; | ||||
|     std::unique_ptr<USB> _usb; | ||||
| }; | ||||
|  | ||||
| IdlePanel* IdlePanel::Create(MainWindow* mainWindow, wxSimplebook* parent) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user