12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #ifndef NVMSELECT_SOURCE
- #define NVMSELECT_SOURCE
- #include "../tools/error.h"
- #include "../tools/files.h"
- #include "../plc/plc.h"
- signed NVMSelect (struct plc * plc, signed old (struct plc *), signed new (struct plc *))
- {
- uint32_t version;
- if (lseek (plc->NVM.file, 0, SEEK_SET))
- {
- error (1, errno, FILE_CANTHOME, plc->NVM.name);
- }
- if (read (plc->NVM.file, &version, sizeof (version)) != sizeof (version))
- {
- error (1, errno, FILE_CANTREAD, plc->NVM.name);
- }
- if (lseek (plc->NVM.file, 0, SEEK_SET))
- {
- error (1, errno, FILE_CANTHOME, plc->NVM.name);
- }
- return (LE32TOH (version) == 0x60000000? old (plc): new (plc));
- }
- #endif
|