Skip to content
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

Fix Ros_Controller_GetActiveAlarmCodes(..) #105

Merged
merged 3 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ControllerStatusIO.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ int Ros_Controller_GetAlarmCode()
return -1;
}

int Ros_Controller_GetActiveAlarmCodes(USHORT active_alarms[MAX_ALARM_COUNT + 1])
int Ros_Controller_GetActiveAlarmCodes(USHORT active_alarms[MAX_ALARM_COUNT + MAX_ERROR_COUNT])
{
MP_ALARM_CODE_RSP_DATA alarmData;
bzero(&alarmData, sizeof(alarmData));
Expand All @@ -736,7 +736,7 @@ int Ros_Controller_GetActiveAlarmCodes(USHORT active_alarms[MAX_ALARM_COUNT + 1]

// if the output array is too small, we can't do anything either. This
// should not happen, but best check for it.
if (alarmData.usAlarmNum + alarmData.usErrorNo > MAX_ALARM_COUNT + 1)
if (alarmData.usAlarmNum + MAX_ERROR_COUNT > MAX_ALARM_COUNT + MAX_ERROR_COUNT)
return -2;

// add all alarms to the output array
Expand Down
2 changes: 1 addition & 1 deletion src/ControllerStatusIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extern void Ros_Controller_SetIOState(ULONG signal, BOOL status);
extern int Ros_Controller_GetAlarmCode();

//retrieve all active alarms (and a possible error) and store them in 'active_alarms'
extern int Ros_Controller_GetActiveAlarmCodes(USHORT active_alarms[MAX_ALARM_COUNT + 1]);
extern int Ros_Controller_GetActiveAlarmCodes(USHORT active_alarms[MAX_ALARM_COUNT + MAX_ERROR_COUNT]);


//#define DUMMY_SERVO_MODE 1 // Dummy servo mode is used for testing with Yaskawa debug controllers
Expand Down
7 changes: 7 additions & 0 deletions src/MotoPlusExterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ extern size_t mpNumBytesFree(void);

extern MP_GRP_ID_TYPE mpCtrlGrpNo2GrpId(int grp_no);

//M+ only defines MAX_ALARM_COUNT, but we'd like to avoid magic nrs
//as much as possible, so we define our own here for errors.
//But only if something hasn't been defined already.
#ifndef MAX_ERROR_COUNT
#define MAX_ERROR_COUNT 1
#endif
gavanderhoorn marked this conversation as resolved.
Show resolved Hide resolved

#endif // MOTOROS2_MOTOPLUS_EXTERNS_H
Loading