Skip to content
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

OneWireDS18B20ThermometerDevice>temperature problem #8

Open
PhotonCoder15 opened this issue Oct 26, 2021 · 0 comments
Open

OneWireDS18B20ThermometerDevice>temperature problem #8

PhotonCoder15 opened this issue Oct 26, 2021 · 0 comments

Comments

@PhotonCoder15
Copy link

OneWireDS18B20ThermometerDevice>temperature fails to close the file after reading it. See new code below.

temperature
"Answer the current temperature value of this device. It is possible the device may not have reported a correct list
of data, so return 999 as a placeholder"
| file data pos tStr |

file := CfsReadFileStream open: devFilePath.
file isCfsError ifFalse: [
	data := file contents.
            file close.                                    "This is the new line."
	((data indexOfSubCollection: 'YES') > 0) ifTrue: [
		pos := data indexOfSubCollection: 't='.
		(pos > 0) ifTrue: [
			tStr := data copyFrom: pos + 2 to: data size.
			^tStr asNumber / 1000.0.
		].
	].
].
^999.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant