Hackable Badge auto datetime
Rsadeika
Posts: 3,837
in Propeller 1
I have a Badge hooked up to the RPi (/ttyUSB0), and I am using Python to talk to the Badge, a snippet:
Thanks
Ray
if inStr.strip() == "SysTime": get_time() clockit = now.strftime("%m/%d/%y") ser.write(clockit) ser.write('%c' % CR) # Send CR clockit = now.strftime("%H/%M/%S") ser.write(clockit) ser.write('%c' % CR) # Send CR #ser.write('Got it!%c' % CR) #time.sleep(.300) print('Sent it')On the Badge, I am using PropGCC to talk to the RPi, a snippet:
char inSysTime[40]; writeStr(term,"SysTime\n"); pause(300); readStr(term,inSysTime,40); oledprint("%s",inSysTime); // Print to oled screen //sprintf(inSysTime,"%s",inSysTime); dt_fromDateStr(dt,inSysTime); //dt_set(dt); pause(100); readStr(term,inSysTime,40); oledprint("%s",inSysTime); // Print to oled screen //sprintf(inSysTime,"%s",inSysTime); dt_fromTimeStr(dt,inSysTime); dt_set(dt); dt = dt_get(); dt_toDateStr(dt,dates); dt_toTimeStr(dt,times); text_size(LARGE); oledprint("%s%s", dates, times); // Getting all zeros for the date and timeFor some reason, that I cannot figure out, 'dt_fromDateStr(dt,inSysTime);' and 'dt_fromTimeStr(dt,inSysTime);', are not working as expected. I have the 'oledprint("%s",inSysTime);' right after the readStr(), which shows the correct format that was received, but it is not converted and stored in dt. Any help on this would be appreciated.
Thanks
Ray
Comments
The Python program is run on the RPi, with a Hackable Badge attached to the ttyUSB0 PORT. When the Badge gets the data, and is running, it seems like the seconds is out of sync by about a half maybe a quarter of a second, close enough for gov work.
I decided to use a Badge, always connected, for the time being, or at least until another solution comes along, to the RPi. I plan to use this connected Badge to datetime sync other badges, plus now I will see if I can get The Python script to handle the Badge data with a file on the RPi. I also found this solution to be cheaper than going with a new QuickStart ($35.00) and an HIB($35.00) verses a Badge ($50.00). I must be the only person working with a Badge using SimpleIDE PropGCC, in the field. A personal opinion, I find working with a Hackable Badge is more useful than working with a QuickStart+other board.
Ray
Python script file.
The Python code has not changed yet, so the previous listing is still valid. The only problem with the Python code is, when you disconnect the USB cable from the Badge, the Python program shuts down. Not sure how to get around that. I was thinking that the program would keep running, that way you could disconnect and reconnect the Badge to get it updated at any time.
Ray
For the Roaming Badge you would press P17 to get the update, and then it shows a continuous running clock.
Now that I have these concepts working, the next step is working with data between the three units, Raspberry Pi, BaseUnit Badge, and the Roaming Badge. Now it starts to get a little complicated, passing data using the IR, and then eventually getting it onto a file on the Raspberry Pi.
Ray
The base unit. The roaming Hackable Badge.
To recap, I have the RPi code that updates my clock for the Base Unit Badge. The Base Unit Badge can auto update the Mobile Badge. Now what I need is, maybe a Raspberry Pi HAT that has IR send/receive hardware on it, with some C code for using the the IR hardware. That way I could free up my Base Unit Badge and make that a Mobile Badge. I am not a hardware guy, so I guess I will just keep my fingers crossed...
I was also so thinking, if the Badge had the IR hardware at the top of the Badge, you could almost have a comfortable remote control setup for driving your ActivityBot around, amongst other uses.
Ray
For my Mobile Badge prototype, I am now ready to start looking into the best way to deal with the use of the EEPROM and the IR Send/Receive items, plus the messages part. My concept really relies on having a Base Unit, whether it is another Badge connected to a Raspberry Pi or a Raspberry Pi with a Propeller RPi HAT that has IR Send/Receive hardware. Another concern, SimpleIDE for the Raspberry Pi does not know how or cannot deal with Propeller RPi HAT attached. A side note: I think that using C with the Badge is a way better way of programming the Badge, strictly my opinion on this.
Why the Base Unit? I think this would be the most efficient way of dealing with data and string transfers. What is available now is a Parallax program that you add some names and data strings which in turn re-programs your Badge. The direction that I am going in is, you have your basic firmware on the Badge and then you would use the Base Unit to upload/download Badge specific information using the IR hardware.
I think that it is more convenient to deal with files, that contain your information for upload, on a Raspberry Pi, using some sort of editor, than using the existing method, but that is my preference. Also when you have captured data on your Badge, once you upload it to the Base Unit, it would be much simpler to use the tools on the RPi to manipulate the uploaded information.
Like I mentioned, in another post, the use of the IR Send/Receive and use of the EEPROM will be an interesting programming session.
Ray