Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:41 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Powershell Date/Time Script

Author Message
crackerjack

Senior Member

Joined: 11/07/2011
Location: Australia
Posts: 164
Posted: 11:59am 18 Mar 2012
Copy link to clipboard 
Print this post

Hi again one-and-all.

A small tip this time. For those who don't have hardware RTC setup and want their Maximite Date and Time updated easily, the following is a small Powershell script to do so. Just run the script from your PC when you connect the MMM/DM and Date and Time is quickly set without fiddling about (or forgetting). There are probably ways of kicking off the script as soon as the USB device is detected, but I do it manually. As for Powershell scripting, that is a whole other story I won't get into now, but for those who are interested, script follows (it could undoubtedly be done in any language of choice which has Serial IO functionality):

[code]
$port = new-Object System.IO.Ports.SerialPort com4,9600,None,8,one
$port.Open()
$port.WriteLine("date$=`"" + (get-date -format ("dd/MM/yyyy")) + "`"")
Start-Sleep -m 100
$port.WriteLine("time$=`"" + (get-date -format ("hh:mm:ss")) + "`"")
Start-Sleep -m 100
$port.WriteLine("Cls");
$port.Close()
[/code]

Note the com4 in the first line should be set to whatever COM Port your MM/DM is connected to, and that the script should be run before firing up TeraTerm (,etc.) and connecting to the *Mite.

Cheers.
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 03:46pm 18 Mar 2012
Copy link to clipboard 
Print this post

That is pretty much the same thing that my button does in MMIDE. Very convenient to set the date/time first thing.
Micromites and Maximites! - Beginning Maximite
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 01:46am 19 Mar 2012
Copy link to clipboard 
Print this post

  crackerjack said   There are probably ways of kicking off the script as soon as the USB device is detected,


Does anybody know how to start this script on usb detection? I have been googling but no success so far. Edited by BobD 2012-03-20
 
Ray B
Senior Member

Joined: 16/02/2007
Location: Australia
Posts: 219
Posted: 09:40am 19 Mar 2012
Copy link to clipboard 
Print this post

Original solution to this challenge using TeraTerm as previously posted by James of Canberra as follows:

http://www.thebackshed.com/forum/forum_posts.asp?TID=3582

Cheers
RayB from Perth WA
 
crackerjack

Senior Member

Joined: 11/07/2011
Location: Australia
Posts: 164
Posted: 10:33am 19 Mar 2012
Copy link to clipboard 
Print this post

Thanks RayB - nice one by James. I think that was posted just before I joined the forum. Good to see a simple solution.

Cheers.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024