Hi,
I am generating some files using the timestamp but it looks like PHL's calender is wrong. Could you please guide me how to fix it ?
Time and Calender Settings
Re: Time and Calender Settings
What a coincidence, I was just working on this. (I have a feeling Hendrik may have played a part here.)
The simple answer is you need to set the correct date and time on the PHL using Linux.
If you ssh into the PHL ('ssh mha@10.0.0.1'), then at the command line set the date (with sudo for permissions):
#sudo date --set="STRING"
Where STRING can be something like:
#sudo date --set="14 MAR 20023 20:00:00"
Since it's Linux, there are a dozen slightly different ways to do this and they all pop up in a google search.
It's possible to combine the ssh and date so you can do this all in one shot from the host computer. An example of this is in the script to connect the PHL to the internet, in ~/openMHA/mha/tools/connect_beaglebone_black_to_internet.sh.
echo Set time on the beaglebone
ssh root@10.0.0.1 "date --set '$(date -R)'"
These methods work but they have a couple major drawbacks:
*The date and time you set will only last until the device is powered down - there's no Real Time Clock on the current PHL.
*A typical subject in a study would have no idea how to do this everyday as needed. (And if all the users in your study know enough Linux to do this you're going to get very biased results anyway from a population made up entirely of tech geeks.)
One solution is to set up something in your GUI to send the local time to the PHL. Then all the subject needs to do is open the GUI and maybe press a button. I haven't tried it, but it's probably not that difficult if you're using Python or another language running on your host system. It is a little tricky (for me at least) if you want to do this in Node Red since the server is actually running on the PHL. I recently stumbled on something that seems to work using the 'template' and 'exec' nodes.
I'll make another post and describe the Node Red method.
The simple answer is you need to set the correct date and time on the PHL using Linux.
If you ssh into the PHL ('ssh mha@10.0.0.1'), then at the command line set the date (with sudo for permissions):
#sudo date --set="STRING"
Where STRING can be something like:
#sudo date --set="14 MAR 20023 20:00:00"
Since it's Linux, there are a dozen slightly different ways to do this and they all pop up in a google search.
It's possible to combine the ssh and date so you can do this all in one shot from the host computer. An example of this is in the script to connect the PHL to the internet, in ~/openMHA/mha/tools/connect_beaglebone_black_to_internet.sh.
echo Set time on the beaglebone
ssh root@10.0.0.1 "date --set '$(date -R)'"
These methods work but they have a couple major drawbacks:
*The date and time you set will only last until the device is powered down - there's no Real Time Clock on the current PHL.
*A typical subject in a study would have no idea how to do this everyday as needed. (And if all the users in your study know enough Linux to do this you're going to get very biased results anyway from a population made up entirely of tech geeks.)
One solution is to set up something in your GUI to send the local time to the PHL. Then all the subject needs to do is open the GUI and maybe press a button. I haven't tried it, but it's probably not that difficult if you're using Python or another language running on your host system. It is a little tricky (for me at least) if you want to do this in Node Red since the server is actually running on the PHL. I recently stumbled on something that seems to work using the 'template' and 'exec' nodes.
I'll make another post and describe the Node Red method.
Re: Time and Calender Settings
The Node Red setup is hard to describe here, I'll make blog post about it to show more detail.
I'm not real familiar with Node Red so this code is of the copy/paste variety. It seems to work though. It makes a button using the 'template' node from under Dashboard. The 'Template' section contains the following:
This 'template' node is connected to an 'exec' node from under the 'function' section. The command section of the node should have
Also the +Append option is selected with 'msg.payload'.
This creates a button that sends the local time to the PHL when pressed.
I'd like to change it to just automatically run when the GUI is opened - need to figure that out.
I'll make a blog post about this.
Bertran are you using Python to write your GUI? I'll look at that. I guess you'd run the previously described 'ssh' approach using a shell command.
I'm not real familiar with Node Red so this code is of the copy/paste variety. It seems to work though. It makes a button using the 'template' node from under Dashboard. The 'Template' section contains the following:
Code: Select all
<script>
this.scope.action = function() {
var Datum = new Date();
return Datum; }
</script>
<md-button ng-click="send({payload:action()})">
Click to set date on PHL.
</md-button>
Code: Select all
sudo date -s
This creates a button that sends the local time to the PHL when pressed.
I'd like to change it to just automatically run when the GUI is opened - need to figure that out.
I'll make a blog post about this.
Bertran are you using Python to write your GUI? I'll look at that. I guess you'd run the previously described 'ssh' approach using a shell command.
-
- Posts: 118
- Joined: Mon Jun 24, 2019 12:51 pm
Re: Time and Calender Settings
As nmichael says, the PHL does not have real-time-clock hardware, and therefore cannot keep track of time and date between reboots. Also, its operating system does not connect to the internet on each reboot to retrieve the current time and date. It will function without internet access, similar to normal hearing aids.bertankursun2 wrote: ↑Tue Mar 14, 2023 9:44 pmI am generating some files using the timestamp but it looks like PHL's calender is wrong.
That said, what is it that you are actually trying to achieve? You think that having a correct timestamp may provide a solution to your problem, but maybe there is another way to solve your problem, so please share what you are trying to achieve. It is not obvious to me.
Re: Time and Calender Settings
Here's what I came up with for Python running on Linux.
Assumes your host machine is connected to the PHL via WiFi of course.
Assumes your host machine is connected to the PHL via WiFi of course.
Code: Select all
import sys
import os
sys.path.append('../../mha/tools/python') #set this so it matches your setup
from openMHA import MHAConnection
mha = MHAConnection("10.0.0.1",33337)
os.system("ssh root@10.0.0.1 \"date --set '$(date -R)'\" ")
.
.
.