I've been working on getting a test IO Rack and Card working (alla the tutorial in the
IO System Guide), but have gotten stuck at a few points. By piecing together some other guides (like the
Custom Function Guide on the Wiki), I've been able to get my code to compile and put it in my Node Hierarchy, but when I run a simulation, I'm not getting the dummy value I programmed. How can I get my programmed output to be reflected in Proview?
Here's my IO Card's code in ra_io_m_rfr.c:
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolmark2classes.h"
#include "rt_io_base.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "rt_io_card_write.h"
#include "rt_io_msg.h"
// Init method
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent *ap, io_sRack *rp, io_sCard *cp)
{
pwr_sClass_RandomFileReaderIO *op = (pwr_sClass_RandomFileReaderIO *)cp->op;
op->Status = pwr_eRFR_StatusEnum_Success;
return IO__SUCCESS;
}
// Close method
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent *ap, io_sRack *rp, io_sCard *cp)
{
return IO__SUCCESS;
}
// Read Method
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent *ap, io_sRack *rp, io_sCard *cp)
{
pwr_sClass_RandomFileReaderIO *op = (pwr_sClass_RandomFileReaderIO *)cp->op;
op->Status = pwr_eRFR_StatusEnum_Read;
*(pwr_tBoolean *)cp->chanlist[0].vbp = 1;
*(pwr_tBoolean *)cp->chanlist[1].vbp = 0;
return IO__SUCCESS;
}
// Write method
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent *ap, io_sRack *rp, io_sCard *cp)
{
pwr_sClass_RandomFileReaderIO *op = (pwr_sClass_RandomFileReaderIO *)cp->op;
op->Status = pwr_eRFR_StatusEnum_Write;
if(*(pwr_tBoolean *)cp->chanlist[1].vbp == 0) {
system("echo \"bye\" >>> /home/pwrp/test.txt");
} else if(*(pwr_tBoolean *)cp->chanlist[1].vbp == 1) {
system("echo \"hi\" >>> /home/pwrp/test.txt");
} else {
system("echo \"idk\" >>> /home/pwrp/test.txt");
}
return IO__SUCCESS;
}
// Every method should be registred here
pwr_dExport pwr_BindIoUserMethods(MotionControl_USBIO) = {
pwr_BindIoUserMethod(IoCardInit),
pwr_BindIoUserMethod(IoCardClose),
pwr_BindIoUserMethod(IoCardRead),
pwr_BindIoUserMethod(IoCardWrite),
pwr_NullMethod
};
Here's my IO Card Configuration: