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

HIL: send time from host #70

Merged
merged 1 commit into from
Feb 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/me/drton/jmavsim/MAVLinkHILSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.TimeZone;

/**
* MAVLinkHILSystem is MAVLink bridge between AbstractVehicle and autopilot connected via MAVLink.
Expand All @@ -26,6 +28,7 @@ public class MAVLinkHILSystem extends MAVLinkSystem {
false; //prefer HIL_ACTUATOR_CONTROLS in case we get both messages
private long hilStateUpdateInterval = -1; //don't publish by default
private long nextHilStatePub = 0;
private long timeThrottleCounter = 0;

/**
* Create MAVLinkHILSimulator, MAVLink system that sends simulated sensors to autopilot and passes controls from
Expand Down Expand Up @@ -245,6 +248,16 @@ public void update(long t) {
sendMessage(msg_gps);
}
}

// SYSTEM TIME from host
if (timeThrottleCounter++ % 1000 == 0) {
System.out.println("Sending time");
MAVLinkMessage msg_system_time = new MAVLinkMessage(schema, "SYSTEM_TIME", sysId, componentId, protocolVersion);
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
msg_system_time.set("time_unix_usec", cal.getTimeInMillis() * 1000);
msg_system_time.set("time_boot_ms", tu/1000);
sendMessage(msg_system_time);
}
}

}