Skip to content

Commit a0b0bba

Browse files
author
daniel
committed
eliminate unneeded "name" argument that was passed before initialization; eliminate rtapi_snprintf() by using new hal_export_functf()
1 parent d0936a1 commit a0b0bba

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/hal/components/boss_plc.c

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ typedef struct {
201201
hal_bit_t limitNeg;
202202
} Limit;
203203

204-
static int Limit_Export(Limit *this, int compId, int id, char *name, char axis);
204+
static int Limit_Export(Limit *this, int compId, int id, char axis);
205205
static void Limit_Init(Limit *this);
206206
static BOOL Limit_IsActive(Limit *this);
207207
static void Limit_Refresh(Limit *this, hal_bit_t override);
@@ -225,7 +225,7 @@ typedef struct {
225225
hal_bit_t lastEnable;
226226
} Amp;
227227

228-
static int Amp_Export(Amp *this, int compId, int id, char *name, char axis);
228+
static int Amp_Export(Amp *this, int compId, int id, char axis);
229229
static void Amp_Init(Amp *this);
230230
static void Amp_Refresh(Amp *this, long period, hal_u32_t readyDelay);
231231

@@ -313,11 +313,11 @@ typedef struct {
313313
// These methods are used for initialization.
314314
static int Plc_Init(Plc *this);
315315
static int Plc_Export(Plc *this, int compId, int id);
316-
static int Plc_ExportFeed(Plc *this, int compId, int id, char *name);
317-
static int Plc_ExportLimits(Plc *this, int compId, int id, char *name);
318-
static int Plc_ExportAmps(Plc *this, int compId, int id, char *name);
319-
static int Plc_ExportSpindle(Plc *this, int compId, int id, char *name);
320-
static int Plc_ExportJog(Plc *this, int compId, int id, char *name);
316+
static int Plc_ExportFeed(Plc *this, int compId, int id);
317+
static int Plc_ExportLimits(Plc *this, int compId, int id);
318+
static int Plc_ExportAmps(Plc *this, int compId, int id);
319+
static int Plc_ExportSpindle(Plc *this, int compId, int id);
320+
static int Plc_ExportJog(Plc *this, int compId, int id);
321321

322322
// These methods are exported to the HAL.
323323
static void Plc_Refresh(void *this, long period);
@@ -468,7 +468,6 @@ static int
468468
Plc_Export(Plc *this, int compId, int id)
469469
{
470470
int msgLevel, error;
471-
char name[HAL_NAME_LEN + 1];
472471

473472
// This function exports a lot of stuff, which results in a lot of
474473
// logging if msg_level is at INFO or ALL. So we save the current value
@@ -478,27 +477,26 @@ Plc_Export(Plc *this, int compId, int id)
478477
rtapi_set_msg_level(RTAPI_MSG_WARN);
479478

480479
// Export pins and parameters.
481-
error = Plc_ExportFeed(this, compId, id, name);
480+
error = Plc_ExportFeed(this, compId, id);
482481

483482
if(!error){
484-
error = Plc_ExportLimits(this, compId, id, name);
483+
error = Plc_ExportLimits(this, compId, id);
485484
}
486485

487486
if(!error){
488-
error = Plc_ExportAmps(this, compId, id, name);
487+
error = Plc_ExportAmps(this, compId, id);
489488
}
490489

491490
if(!error){
492-
error = Plc_ExportSpindle(this, compId, id, name);
491+
error = Plc_ExportSpindle(this, compId, id);
493492
}
494493
if(!error){
495-
error = Plc_ExportJog(this, compId, id, name);
494+
error = Plc_ExportJog(this, compId, id);
496495
}
497496

498497
// Export functions.
499498
if(!error){
500-
rtapi_snprintf(name, sizeof(name), "boss_plc.%d.refresh", id);
501-
error = hal_export_funct(name, Plc_Refresh, this, 1, 0, compId);
499+
error = hal_export_functf(Plc_Refresh, this, 1, 0, compId, "boss_plc.%d.refresh", id);
502500
}
503501

504502
// Restore saved message level.
@@ -509,7 +507,7 @@ Plc_Export(Plc *this, int compId, int id)
509507

510508

511509
static int
512-
Plc_ExportFeed(Plc *this, int compId, int id, char *name)
510+
Plc_ExportFeed(Plc *this, int compId, int id)
513511
{
514512
int error;
515513

@@ -578,7 +576,7 @@ Plc_ExportFeed(Plc *this, int compId, int id, char *name)
578576

579577

580578
static int
581-
Plc_ExportLimits(Plc *this, int compId, int id, char *name)
579+
Plc_ExportLimits(Plc *this, int compId, int id)
582580
{
583581
int error;
584582

@@ -592,11 +590,11 @@ Plc_ExportLimits(Plc *this, int compId, int id, char *name)
592590
}
593591

594592
if(!error){
595-
error = Limit_Export(&this->xLimit, compId, id, name, axisNames[0]);
593+
error = Limit_Export(&this->xLimit, compId, id, axisNames[0]);
596594
}
597595

598596
if(!error){
599-
error = Limit_Export(&this->yLimit, compId, id, name, axisNames[1]);
597+
error = Limit_Export(&this->yLimit, compId, id, axisNames[1]);
600598
}
601599

602600
if(!error){
@@ -642,7 +640,7 @@ Plc_ExportLimits(Plc *this, int compId, int id, char *name)
642640

643641

644642
static int
645-
Plc_ExportAmps(Plc *this, int compId, int id, char *name)
643+
Plc_ExportAmps(Plc *this, int compId, int id)
646644
{
647645
int error, i;
648646
Amp *pAmp;
@@ -652,15 +650,15 @@ Plc_ExportAmps(Plc *this, int compId, int id, char *name)
652650

653651
pAmp = this->amps;
654652
for(i = 0; i < NUM_AXIS && !error; i++, pAmp++){
655-
error = Amp_Export(pAmp, compId, id, name, axisNames[i]);
653+
error = Amp_Export(pAmp, compId, id, axisNames[i]);
656654
}
657655

658656
return(error);
659657
}
660658

661659

662660
static int
663-
Plc_ExportSpindle(Plc *this, int compId, int id, char *name)
661+
Plc_ExportSpindle(Plc *this, int compId, int id)
664662
{
665663
int error;
666664

@@ -742,7 +740,7 @@ Plc_ExportSpindle(Plc *this, int compId, int id, char *name)
742740

743741

744742
static int
745-
Plc_ExportJog(Plc *this, int compId, int id, char *name)
743+
Plc_ExportJog(Plc *this, int compId, int id)
746744
{
747745
int error, i;
748746

@@ -969,7 +967,7 @@ Plc_RefreshJog(Plc *this, long period)
969967
******************************************************************************/
970968

971969
static int
972-
Limit_Export(Limit *this, int compId, int id, char *name, char axis)
970+
Limit_Export(Limit *this, int compId, int id, char axis)
973971
{
974972
int error;
975973

@@ -1084,7 +1082,7 @@ Limit_Refresh(Limit *this, hal_bit_t override)
10841082
******************************************************************************/
10851083

10861084
static int
1087-
Amp_Export(Amp *this, int compId, int id, char *name, char axis)
1085+
Amp_Export(Amp *this, int compId, int id, char axis)
10881086
{
10891087
int error;
10901088

0 commit comments

Comments
 (0)