From 8e7fd4da8133e21afa2ecf8e944acbff589d2a40 Mon Sep 17 00:00:00 2001 From: ligi Date: Sat, 9 Apr 2011 04:32:26 +0000 Subject: [PATCH] adding juavtalk git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3132 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../openpilotgcs/src/libs/juavtalk/build.xml | 39 +++++++ .../src/org/openpilot/uavtalk/CRC8.java | 86 +++++++++++++++ .../src/org/openpilot/uavtalk/UAVObject.java | 69 ++++++++++++ .../uavtalk/UAVObjectFieldDescription.java | 89 +++++++++++++++ .../openpilot/uavtalk/UAVObjectMetaData.java | 100 +++++++++++++++++ .../uavtalk/UAVObjectsInterface.java | 37 +++++++ .../openpilot/uavtalk/UAVTalkDefinitions.java | 57 ++++++++++ .../org/openpilot/uavtalk/UAVTalkHelper.java | 102 ++++++++++++++++++ .../org/openpilot/uavtalk/ValueParser.java | 34 ++++++ 9 files changed, 613 insertions(+) create mode 100644 ground/openpilotgcs/src/libs/juavtalk/build.xml create mode 100644 ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/CRC8.java create mode 100644 ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/UAVObject.java create mode 100644 ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/UAVObjectFieldDescription.java create mode 100644 ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/UAVObjectMetaData.java create mode 100644 ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/UAVObjectsInterface.java create mode 100644 ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/UAVTalkDefinitions.java create mode 100644 ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/UAVTalkHelper.java create mode 100644 ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/ValueParser.java diff --git a/ground/openpilotgcs/src/libs/juavtalk/build.xml b/ground/openpilotgcs/src/libs/juavtalk/build.xml new file mode 100644 index 000000000..f9ec55d5b --- /dev/null +++ b/ground/openpilotgcs/src/libs/juavtalk/build.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/CRC8.java b/ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/CRC8.java new file mode 100644 index 000000000..6a13e886f --- /dev/null +++ b/ground/openpilotgcs/src/libs/juavtalk/src/org/openpilot/uavtalk/CRC8.java @@ -0,0 +1,86 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package org.openpilot.uavtalk; + +/** + ****************************************************************************** + * + * @file CRC8.java + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011. + * @brief functions to calculate CRC8 checksums for usage in the UAVTalk-Protocol + * + **************************************************************************** +*/ +public class CRC8 { + + /** + * update a CRC8 value with one byte of data + * + * @param crc - start CRC8 Value + * @param data - data byte to update the CRC8-Checksum with + * @return - the new CRC value + */ + public static byte byteUpdate(byte crc, byte data) { + return (byte)CRC8_TABLE[crc&0xFF ^ data&0xFF]; + } + + /** + * update a CRC8 value with an byte-array + * + * @param crc - start CRC8 Value + * @param data - data byte-array to update the CRC8-Checksum with + * @return - the new CRC value + */ + public static byte arrayUpdate(byte crc, byte[] data, int length) { + for (int i=0;i>8)&0xFF); + res[4]=(byte)((obj_id)&0xFF); + res[5]=(byte)((obj_id>>8)&0xFF); + res[6]=(byte)((obj_id>>16)&0xFF); + res[7]=(byte)((obj_id>>24)&0xFF); + + + for (int i=0;i