|
5 | 5 |
|
6 | 6 | from science_mode_4.layer import Layer |
7 | 7 | from science_mode_4.protocol.commands import Commands |
| 8 | +from science_mode_4.protocol.exceptions import ProtocolError |
8 | 9 | from science_mode_4.utils.logger import logger |
9 | 10 | from .dyscom_types import DyscomFrequencyOut, DyscomGetOperationModeType, DyscomInitState, DyscomPowerModuleType,\ |
10 | 11 | DyscomPowerModulePowerType, DyscomSignalType, DyscomSysState, DyscomSysType |
@@ -37,7 +38,7 @@ async def init(self, params: DyscomInitParams) -> DyscomInitResult: |
37 | 38 | ack: PacketDyscomInitAck = await self.send_packet_and_wait(p) |
38 | 39 | self._check_result_error(ack.result_error, "DyscomInit") |
39 | 40 | if ack.init_state not in [DyscomInitState.UNUSED, DyscomInitState.SUCCESS]: |
40 | | - raise ValueError(f"Dyscom error init {ack.init_state.name}") |
| 41 | + raise ProtocolError(f"Dyscom error init {ack.init_state.name}") |
41 | 42 |
|
42 | 43 | logger().info("Dyscom init, measurement_file_id: %s, state: %s, frequency: %s",\ |
43 | 44 | ack.measurement_file_id, ack.init_state.name, ack.frequency_out.name) |
@@ -143,7 +144,7 @@ async def sys(self, sys_type: DyscomSysType, filename: str = "") -> DyscomSysRes |
143 | 144 | ack: PacketDyscomSysAck = await self.send_packet_and_wait(p) |
144 | 145 | self._check_result_error(ack.result_error, "DyscomSys") |
145 | 146 | if ack.state not in [DyscomSysState.SUCCESSFUL]: |
146 | | - raise ValueError(f"Dyscom error sys {ack.state.name}") |
| 147 | + raise ProtocolError(f"Dyscom error sys {ack.state.name}") |
147 | 148 |
|
148 | 149 | logger().info("Dyscom sys, type: %s, state: %s, filename: %s", ack.sys_type.name, ack.state.name, ack.filename) |
149 | 150 | return DyscomSysResult(ack.sys_type, ack.state, ack.filename) |
@@ -190,7 +191,7 @@ async def get_file_content(self, filename: str) -> bytes: |
190 | 191 | """Gets content of a file. Device must be in Idle operating mode""" |
191 | 192 | om = await self.get_operation_mode() |
192 | 193 | if om != DyscomGetOperationModeType.IDLE: |
193 | | - raise ValueError(f"Error wrong operation mode {om.name}") |
| 194 | + raise ProtocolError(f"Error wrong operation mode {om.name}") |
194 | 195 |
|
195 | 196 | # get meta information and sets device in mode DATATRANSFER_PRE |
196 | 197 | # we need number of blocks to know how many SendFile commands we expect |
|
0 commit comments