mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Remove JNI logging (#1872)
This commit is contained in:
committed by
Peter Johnson
parent
3e0f7d0995
commit
dd928b4cbf
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -16,21 +16,10 @@
|
||||
#include "HALUtil.h"
|
||||
#include "edu_wpi_first_hal_can_CANJNI.h"
|
||||
#include "hal/CAN.h"
|
||||
#include "hal/cpp/Log.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::java;
|
||||
|
||||
// set the logging level
|
||||
// TLogLevel canJNILogLevel = logDEBUG;
|
||||
TLogLevel canJNILogLevel = logERROR;
|
||||
|
||||
#define CANJNI_LOG(level) \
|
||||
if (level > canJNILogLevel) \
|
||||
; \
|
||||
else \
|
||||
Log().Get(level)
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
@@ -42,37 +31,14 @@ JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_can_CANJNI_FRCNetCommCANSessionMuxSendMessage
|
||||
(JNIEnv* env, jclass, jint messageID, jbyteArray data, jint periodMs)
|
||||
{
|
||||
CANJNI_LOG(logDEBUG) << "Calling CANJNI FRCNetCommCANSessionMuxSendMessage";
|
||||
|
||||
JByteArrayRef dataArray{env, data};
|
||||
|
||||
const uint8_t* dataBuffer =
|
||||
reinterpret_cast<const uint8_t*>(dataArray.array().data());
|
||||
uint8_t dataSize = dataArray.array().size();
|
||||
|
||||
CANJNI_LOG(logDEBUG) << "Message ID ";
|
||||
CANJNI_LOG(logDEBUG).write_hex(messageID);
|
||||
|
||||
if (logDEBUG <= canJNILogLevel) {
|
||||
if (dataBuffer) {
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::raw_svector_ostream str(buf);
|
||||
for (int32_t i = 0; i < dataSize; i++) {
|
||||
str.write_hex(dataBuffer[i]) << ' ';
|
||||
}
|
||||
|
||||
Log().Get(logDEBUG) << "Data: " << str.str();
|
||||
} else {
|
||||
CANJNI_LOG(logDEBUG) << "Data: null";
|
||||
}
|
||||
}
|
||||
|
||||
CANJNI_LOG(logDEBUG) << "Period: " << periodMs;
|
||||
|
||||
int32_t status = 0;
|
||||
HAL_CAN_SendMessage(messageID, dataBuffer, dataSize, periodMs, &status);
|
||||
|
||||
CANJNI_LOG(logDEBUG) << "Status: " << status;
|
||||
CheckCANStatus(env, status, messageID);
|
||||
}
|
||||
|
||||
@@ -86,9 +52,6 @@ Java_edu_wpi_first_hal_can_CANJNI_FRCNetCommCANSessionMuxReceiveMessage
|
||||
(JNIEnv* env, jclass, jobject messageID, jint messageIDMask,
|
||||
jobject timeStamp)
|
||||
{
|
||||
CANJNI_LOG(logDEBUG)
|
||||
<< "Calling CANJNI FRCNetCommCANSessionMuxReceiveMessage";
|
||||
|
||||
uint32_t* messageIDPtr =
|
||||
reinterpret_cast<uint32_t*>(env->GetDirectBufferAddress(messageID));
|
||||
uint32_t* timeStampPtr =
|
||||
@@ -101,28 +64,6 @@ Java_edu_wpi_first_hal_can_CANJNI_FRCNetCommCANSessionMuxReceiveMessage
|
||||
HAL_CAN_ReceiveMessage(messageIDPtr, messageIDMask, buffer, &dataSize,
|
||||
timeStampPtr, &status);
|
||||
|
||||
CANJNI_LOG(logDEBUG) << "Message ID ";
|
||||
CANJNI_LOG(logDEBUG).write_hex(*messageIDPtr);
|
||||
|
||||
if (logDEBUG <= canJNILogLevel) {
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::raw_svector_ostream str(buf);
|
||||
|
||||
for (int32_t i = 0; i < dataSize; i++) {
|
||||
// Pad one-digit data with a zero
|
||||
if (buffer[i] <= 16) {
|
||||
str << '0';
|
||||
}
|
||||
|
||||
str.write_hex(buffer[i]) << ' ';
|
||||
}
|
||||
|
||||
Log().Get(logDEBUG) << "Data: " << str.str();
|
||||
}
|
||||
|
||||
CANJNI_LOG(logDEBUG) << "Timestamp: " << *timeStampPtr;
|
||||
CANJNI_LOG(logDEBUG) << "Status: " << status;
|
||||
|
||||
if (!CheckCANStatus(env, status, *messageIDPtr)) return nullptr;
|
||||
return MakeJByteArray(env,
|
||||
wpi::StringRef{reinterpret_cast<const char*>(buffer),
|
||||
@@ -138,8 +79,6 @@ JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_can_CANJNI_GetCANStatus
|
||||
(JNIEnv* env, jclass, jobject canStatus)
|
||||
{
|
||||
CANJNI_LOG(logDEBUG) << "Calling CANJNI HAL_CAN_GetCANStatus";
|
||||
|
||||
float percentBusUtilization = 0;
|
||||
uint32_t busOffCount = 0;
|
||||
uint32_t txFullCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user