-
Notifications
You must be signed in to change notification settings - Fork 195
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
FSU Speed Limit Handling #542
Changes from all commits
544c41d
305136f
6d69201
5c7870e
196b5c0
9e3babc
0654dfa
0adc258
9c6ff7d
961183a
860fa61
3166e21
d4e4073
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//debug.c | ||
// | ||
|
||
#include "motoPlus.h" | ||
|
||
#define MAX_DEBUG_MESSAGE_SIZE 1024 | ||
|
||
#if (YRC1000||YRC1000u) | ||
|
||
#define DEBUG_UDP_PORT_NUMBER 21789 | ||
#define SO_BROADCAST 0x0020 | ||
|
||
#define MP_USER_LAN1 1 /* general LAN interface1 */ | ||
#define MP_USER_LAN2 2 /* general LAN interface2(only YRC1000) */ | ||
|
||
extern STATUS setsockopt(int s, int level, int optname, char* optval, int optlen); | ||
extern int mpNICData(USHORT if_no, ULONG* ip_addr, ULONG* subnet_mask, UCHAR* mac_addr, ULONG* default_gw); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is YRC1000 (and micro) only. So you probably want a conditional flag around this whole file. |
||
|
||
int ros_DebugSocket = -1; | ||
struct sockaddr_in ros_debug_destAddr1; | ||
|
||
void Ros_Debug_Init() | ||
{ | ||
ULONG ip_be; | ||
ULONG subnetmask_be; | ||
ULONG gateway_be; | ||
int broadcastVal = 1; | ||
UCHAR mac[6]; | ||
|
||
ros_DebugSocket = mpSocket(AF_INET, SOCK_DGRAM, 0); | ||
setsockopt(ros_DebugSocket, SOL_SOCKET, SO_BROADCAST, (char*)&broadcastVal, sizeof(broadcastVal)); | ||
|
||
mpNICData(MP_USER_LAN1, &ip_be, &subnetmask_be, mac, &gateway_be); | ||
|
||
ros_debug_destAddr1.sin_addr.s_addr = ip_be | (~subnetmask_be); | ||
ros_debug_destAddr1.sin_family = AF_INET; | ||
ros_debug_destAddr1.sin_port = mpHtons(DEBUG_UDP_PORT_NUMBER); | ||
} | ||
|
||
void Debug_BroadcastBytes(char* bytes, int len) | ||
{ | ||
if (ros_DebugSocket == -1) | ||
Ros_Debug_Init(); | ||
|
||
mpSendTo(ros_DebugSocket, bytes, len, 0, (struct sockaddr*)&ros_debug_destAddr1, sizeof(struct sockaddr_in)); | ||
} | ||
#endif | ||
|
||
|
||
void Debug_BroadcastMsg(const char *fmt, ...) | ||
{ | ||
#if defined(YRC1000)||defined(YRC1000u) | ||
char str[MAX_DEBUG_MESSAGE_SIZE]; | ||
va_list va; | ||
|
||
memset(str, 0x00, MAX_DEBUG_MESSAGE_SIZE); | ||
|
||
va_start(va, fmt); | ||
vsnprintf(str, MAX_DEBUG_MESSAGE_SIZE, fmt, va); | ||
va_end(va); | ||
|
||
if (ros_DebugSocket == -1) | ||
Ros_Debug_Init(); | ||
|
||
mpSendTo(ros_DebugSocket, str, strlen(str), 0, (struct sockaddr*)&ros_debug_destAddr1, sizeof(struct sockaddr_in)); | ||
#else | ||
// Broadcast not available, just print to terminal | ||
va_list va; | ||
va_start(va, fmt); | ||
printf(fmt, va); | ||
va_end(va); | ||
#endif | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//debug.h | ||
// | ||
#ifndef _DEBUG_H_ | ||
#define _DEBUG_H_ | ||
|
||
#if (YRC1000||YRC1000u) | ||
extern void Ros_Debug_Init(); | ||
#endif | ||
extern void Debug_BroadcastMsg(const char *fmt, ...); | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ | |
*/ | ||
|
||
#include "MotoROS.h" | ||
|
||
#include "debug.h" | ||
|
||
#ifdef DEBUG | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous comment:
|
||
#warning Debug messages in MotoPlus *will* affect application performance (disable this in SimpleMessage.h) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
obj\Win32\YRC1000u\\_IsIncrementalBuild |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've got some stuff in the MotoROS2 project to obfuscate externs like this. We think it's probably portable to MotoROS1.