123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #ifndef FLASHDEVICE2_SOURCE
- #define FLASHDEVICE2_SOURCE
- #include "../plc/plc.h"
- signed FlashDevice2 (struct plc * plc, uint32_t options)
- {
- char firmware [256];
- if (plc->SFT.file != -1)
- {
- if (FlashSoftloader (plc, options))
- {
- return (-1);
- }
- }
- if ((plc->NVM.file != -1) && (plc->PIB.file != -1))
- {
- if (FlashFirmware (plc, options))
- {
- return (-1);
- }
- }
- else if (plc->PIB.file != -1)
- {
- if (FlashParameters (plc, options))
- {
- return (-1);
- }
- }
- if(IsFlashExists(plc))
- {
- if (ResetDevice (plc))
- {
- return (-1);
- }
- }
- sleep (5);
- if (WaitForStart (plc, firmware, sizeof (firmware)))
- {
- return (-1);
- }
- return (0);
- }
- signed FlashDevice2_no_wait(struct plc* plc, uint32_t options)
- {
- if (plc->SFT.file != -1)
- {
- if (FlashSoftloader(plc, options))
- {
- return (-1);
- }
- }
- if ((plc->NVM.file != -1) && (plc->PIB.file != -1))
- {
- if (FlashFirmware(plc, options))
- {
- return (-1);
- }
- }
- else if (plc->PIB.file != -1)
- {
- if (FlashParameters(plc, options))
- {
- return (-1);
- }
- }
- if (IsFlashExists(plc))
- {
- if (ResetDevice(plc))
- {
- return (-1);
- }
- }
- return (0);
- }
- #endif
|