-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Output CSV and implement packet logger #226
base: dev
Are you sure you want to change the base?
Conversation
@@ -104,10 +111,29 @@ class PacketLogger extends Component<IProps, IState> { | |||
this.setState((prevState) => ({ data: [newData].concat(prevState.data) })); | |||
} | |||
|
|||
exportPacket(): void { | |||
fs.writeFile( | |||
'packetLog.csv', |
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.
Should specify that it's the received packet log, and include the timestamp so it doesn't overwrite if we save multiple logs before we analyze them.
(err) => { | ||
if (err) console.log(err); | ||
else { | ||
console.log('File written successfully\n'); | ||
} |
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.
We don't need to log that it was a success. We can assume it was successful if it didn't give an error. We should log this error to the app's logger, not the console log. rovecomm.emit('all', 'Error saving log');
@@ -131,6 +157,9 @@ class PacketLogger extends Component<IProps, IState> { | |||
showPageSizeOptions={false} | |||
style={{ textAlign: 'center', margin: 'auto' }} | |||
/> | |||
<button type="button" style={buttons} onClick={() => this.exportPacket()}> |
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.
You should pass the exportPacket function as a parameter here instead of creating an anonymous function just to call it.
const h1Style: CSS.Properties = { | ||
fontFamily: 'arial', | ||
fontSize: '18px', | ||
margin: '5px 0px', | ||
}; |
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.
Unused css
const selectbox: CSS.Properties = { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
width: '75%', | ||
margin: '2.5px', | ||
justifyContent: 'space-around', | ||
}; | ||
const selector: CSS.Properties = { | ||
width: '200px', | ||
}; |
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.
Unused CSS
|
||
addData(newData: any): void { | ||
this.setState((prevState) => ({ data: [newData].concat(prevState.data) })); | ||
} |
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.
Should add a clear button or only save up to like 100 packets for this since we don't want it to eat up the entire system's memory over the entire time of a task saving every packet that was sent.
// import "../../node_modules/react-table-v6/react-table.css" | ||
import { rovecomm, RovecommManifest } from '../../Core/RoveProtocol/Rovecomm'; |
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.
Manifest is unused, so can be removed. Commented line can be removed
This PR allows logged packets to be saved to a CSV file. It also adds a log for packets sent by Basestation.