示例#1
0
void RudderSendNmea(void)
{
	// Set CAN header information.
	tCanMessage msg;
	PackagePgn127245(&msg, nodeId, 0xFF, 0xF, 0.0, rudderSensorData.RudderPositionAngle);

	// And finally transmit it.
	ecan1_buffered_transmit(&msg);
}
示例#2
0
void BallastSendNmea(void)
{
	// Set CAN header information.
	CanMessage msg;
	PackagePgn127245(&msg, nodeId, 0xFF, 0xF, NAN, ballastSensorData.BallastPositionAngle);

	// And finally transmit it.
	Ecan1Transmit(&msg);
}
示例#3
0
void HilNodeTimer100Hz(void)
{
    // Track the messages to be transmit for this timestep.
	// Here we emulate the same transmission frequency of the messages actually transmit
	// by the onboard sensors.
    static uint8_t msgs[ECAN_MSGS_SIZE];

	// Check the status of the rudder, setting it if it's changed.
	if (++rudderTimeoutCounter >= RUDDER_TIMEOUT_PERIOD) {
		nodeStatus &= ~NODE_STATUS_FLAG_RUDDER_ACTIVE;
	}

	// We don't do any transmission of CAN messages if we're inactive.
	if (!HIL_IS_ACTIVE()) {
		return;
	}

    uint8_t messagesToSend = GetMessagesForTimestep(&sched, msgs);
    int i;
    CanMessage msg;
    for (i = 0; i < messagesToSend; ++i) {
        switch (msgs[i]) {
			// Emulate the RC node
            case SCHED_ID_RC_STATUS:
                CanMessagePackageStatus(&msg, CAN_NODE_RC, 0, 0, 0);
                Ecan1Transmit(&msg);
            break;
			// Emulate the rudder node
            case SCHED_ID_RUDDER_ANGLE:
				if (!(nodeStatus & NODE_STATUS_FLAG_RUDDER_ACTIVE)) {
					PackagePgn127245(&msg, nodeId, 0xFF, 0xF, NAN, hilReceivedData.data.rAngle);
					Ecan1Transmit(&msg);
				}
            break;
            case SCHED_ID_RUDDER_LIMITS:
				if (!(nodeStatus & NODE_STATUS_FLAG_RUDDER_ACTIVE)) {
					CanMessagePackageRudderDetails(&msg, 0, 0, 0, false, false, true, true, false);
					Ecan1Transmit(&msg);
				}
            break;
			// Emulate the ACS300
            case SCHED_ID_THROTTLE_STATUS:
                Acs300PackageHeartbeat(&msg, (uint16_t)hilReceivedData.data.tSpeed, 0, 0, 0);
                Ecan1Transmit(&msg);
            break;
			// Emulate the GPS200
            case SCHED_ID_LAT_LON:
                PackagePgn129025(&msg, nodeId, hilReceivedData.data.gpsLatitude, hilReceivedData.data.gpsLongitude);
                Ecan1Transmit(&msg);
            break;
            case SCHED_ID_COG_SOG:
                PackagePgn129026(&msg, nodeId, 0xFF, 0x7, hilReceivedData.data.gpsCog, hilReceivedData.data.gpsSog);
                Ecan1Transmit(&msg);
            break;
            case SCHED_ID_GPS_FIX:
                PackagePgn129539(&msg, nodeId, 0xFF, PGN_129539_MODE_3D, PGN_129539_MODE_3D, 100, 100, 100);
                Ecan1Transmit(&msg);
            break;
        }
    }
}