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

support set time command #12

Open
RonanHiggins opened this issue Jun 11, 2024 · 0 comments
Open

support set time command #12

RonanHiggins opened this issue Jun 11, 2024 · 0 comments

Comments

@RonanHiggins
Copy link
Contributor

RonanHiggins commented Jun 11, 2024

you can set the time by hand if there are issues with the ntp/ptp. ideally only done for testing

image

curl command

curl 'http://172.16.5.95:8080/?Module=DataSets.CmdGeneralTransfer&Chapter=3&Command' -X POST --data-raw 'Command=Set+Time&Year=2024&Day+of+Year=163&Seconds+of+Day=24595'

python script to set time on the ACU

import requests
from datetime import datetime

def get_current_time():
    # Get the current time
    now = datetime.utcnow()
    
    # Extract the required components
    year = now.year
    day_of_year = now.timetuple().tm_yday
    seconds_of_day = now.hour * 3600 + now.minute * 60 + now.second
    
    # Return the formatted time
    return year, day_of_year, seconds_of_day

def send_time_data(url):
    # Get the current time
    year, day_of_year, seconds_of_day = get_current_time()
    
    # Prepare the data payload
    data = {
        'Command': 'Set Time',
        'Year': year,
        'Day of Year': day_of_year,
        'Seconds of Day': seconds_of_day
    }
    
    # Send the POST request
    response = requests.post(url, data=data)
    
    # Return the response
    return response

# Define the URL
url = 'http://172.16.5.95:8080/?Module=DataSets.CmdGeneralTransfer&Chapter=3&Command'

# Send the time data
response = send_time_data(url)

# Print the response
print(f"Status Code: {response.status_code}")
print(f"Response Text: {response.text}")
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