Merge "Add float support to binary event log."
This commit is contained in:
commit
07e07aa475
3 changed files with 36 additions and 3 deletions
|
|
@ -492,6 +492,7 @@ typedef enum {
|
||||||
EVENT_TYPE_LONG = 1,
|
EVENT_TYPE_LONG = 1,
|
||||||
EVENT_TYPE_STRING = 2,
|
EVENT_TYPE_STRING = 2,
|
||||||
EVENT_TYPE_LIST = 3,
|
EVENT_TYPE_LIST = 3,
|
||||||
|
EVENT_TYPE_FLOAT = 4,
|
||||||
} AndroidEventLogType;
|
} AndroidEventLogType;
|
||||||
#define sizeof_AndroidEventLogType sizeof(typeof_AndroidEventLogType)
|
#define sizeof_AndroidEventLogType sizeof(typeof_AndroidEventLogType)
|
||||||
#define typeof_AndroidEventLogType unsigned char
|
#define typeof_AndroidEventLogType unsigned char
|
||||||
|
|
@ -510,6 +511,13 @@ typedef enum {
|
||||||
sizeof(longBuf)); \
|
sizeof(longBuf)); \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef LOG_EVENT_FLOAT
|
||||||
|
#define LOG_EVENT_FLOAT(_tag, _value) { \
|
||||||
|
float floatBuf = _value; \
|
||||||
|
(void) android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \
|
||||||
|
sizeof(floatBuf)); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifndef LOG_EVENT_STRING
|
#ifndef LOG_EVENT_STRING
|
||||||
#define LOG_EVENT_STRING(_tag, _value) \
|
#define LOG_EVENT_STRING(_tag, _value) \
|
||||||
(void) __android_log_bswrite(_tag, _value);
|
(void) __android_log_bswrite(_tag, _value);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <log/logd.h>
|
#include <log/logd.h>
|
||||||
|
|
@ -432,7 +433,7 @@ static inline uint64_t get8LE(const uint8_t* src)
|
||||||
|
|
||||||
low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
|
low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
|
||||||
high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
|
high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
|
||||||
return ((long long) high << 32) | (long long) low;
|
return ((uint64_t) high << 32) | (uint64_t) low;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -490,7 +491,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData,
|
||||||
case EVENT_TYPE_LONG:
|
case EVENT_TYPE_LONG:
|
||||||
/* 64-bit signed long */
|
/* 64-bit signed long */
|
||||||
{
|
{
|
||||||
long long lval;
|
uint64_t lval;
|
||||||
|
|
||||||
if (eventDataLen < 8)
|
if (eventDataLen < 8)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -498,7 +499,30 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData,
|
||||||
eventData += 8;
|
eventData += 8;
|
||||||
eventDataLen -= 8;
|
eventDataLen -= 8;
|
||||||
|
|
||||||
outCount = snprintf(outBuf, outBufLen, "%lld", lval);
|
outCount = snprintf(outBuf, outBufLen, "%" PRId64, lval);
|
||||||
|
if (outCount < outBufLen) {
|
||||||
|
outBuf += outCount;
|
||||||
|
outBufLen -= outCount;
|
||||||
|
} else {
|
||||||
|
/* halt output */
|
||||||
|
goto no_room;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EVENT_TYPE_FLOAT:
|
||||||
|
/* float */
|
||||||
|
{
|
||||||
|
uint32_t ival;
|
||||||
|
float fval;
|
||||||
|
|
||||||
|
if (eventDataLen < 4)
|
||||||
|
return -1;
|
||||||
|
ival = get4LE(eventData);
|
||||||
|
fval = *(float*)&ival;
|
||||||
|
eventData += 4;
|
||||||
|
eventDataLen -= 4;
|
||||||
|
|
||||||
|
outCount = snprintf(outBuf, outBufLen, "%f", fval);
|
||||||
if (outCount < outBufLen) {
|
if (outCount < outBufLen) {
|
||||||
outBuf += outCount;
|
outBuf += outCount;
|
||||||
outBufLen -= outCount;
|
outBufLen -= outCount;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
# 2: long
|
# 2: long
|
||||||
# 3: string
|
# 3: string
|
||||||
# 4: list
|
# 4: list
|
||||||
|
# 5: float
|
||||||
#
|
#
|
||||||
# The data unit is a number taken from the following list:
|
# The data unit is a number taken from the following list:
|
||||||
# 1: Number of objects
|
# 1: Number of objects
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue