-
Notifications
You must be signed in to change notification settings - Fork 847
fix: prevent LA pin crash in multimeter (#2955) #3053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: flutter
Are you sure you want to change the base?
Changes from all commits
6c5b8c5
3455c4d
ebe1486
2ee174a
f60fd76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ class ScienceLab { | |
| List<DigitalChannel> dChannels = []; | ||
| Map<String, DACChannel> dacChannels = {}; | ||
| static final double capacitorDischargeVoltage = 0.01 * 3.3; | ||
| static const double frequencyError = -1; | ||
|
|
||
| late CommunicationHandler mCommunicationHandler; | ||
| late SocketClient mSocketClient; | ||
|
|
@@ -582,7 +583,7 @@ class ScienceLab { | |
| } | ||
| } else { | ||
| logger.e("Error: Can't load data"); | ||
| return -1; | ||
| return frequencyError; | ||
| } | ||
| dChan.loadData(tempMap, data); | ||
|
|
||
|
|
@@ -609,9 +610,27 @@ class ScienceLab { | |
| await Future.delayed(const Duration(milliseconds: 250)); | ||
| } catch (e) { | ||
| logger.e("Error in getFrequency: $e"); | ||
| return frequencyError; | ||
| } | ||
|
|
||
| // Null check to prevent crash when getLAInitialStates fails | ||
| if (data == null) { | ||
| logger.e("Error in getFrequency: getLAInitialStates returned null"); | ||
| return frequencyError; | ||
| } | ||
|
|
||
| int? channelNumber = calculateDigitalChannel(channel); | ||
| if (channelNumber == null) { | ||
| logger.e("Error in getFrequency: invalid channel $channel"); | ||
| return frequencyError; | ||
| } | ||
|
Comment on lines
+622
to
+626
|
||
|
|
||
| try { | ||
| return await fetchLAChannelFrequency(channelNumber, data); | ||
| } catch (e) { | ||
| logger.e("Error in getFrequency while fetching LA channel frequency: $e"); | ||
| return frequencyError; | ||
| } | ||
| return await fetchLAChannelFrequency( | ||
| calculateDigitalChannel(channel)!, data!); | ||
| } | ||
|
Comment on lines
+625
to
634
|
||
|
|
||
| Future<void> startOneChannelLA(String? channel, int? channelMode, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetchLAChannelFrequencystill usestemp!earlier in this method right afterfetchIntDataFromLA(...). SincefetchIntDataFromLAcan return null on communication errors, this path can still crash with a null-check-operator exception. Add a null guard fortempand returnfrequencyErrorbefore indexing/usingtemp.length.