133 #ifndef DISABLE_DAISYCHAIN_COM_CALL
137 #if (HARDWARE != SIMULATION)
145 #include <sys/mman.h>
148 #ifndef DISABLE_DAISYCHAIN_COM_CALL
149 static DATA8 DaisyBuf[64];
159 gOutputInstance= _Instance;
170 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
181 for(Tmp = 0; Tmp <
OUTPUTS; Tmp++)
183 OutputInstance.
Owner[Tmp] = 0;
186 StopArr[0] = (
DATA8)opOUTPUT_STOP;
189 if (OutputInstance.
PwmFile >= 0)
191 write(OutputInstance.
PwmFile,StopArr,3);
198 RESULT Result = FAIL;
205 OutputInstance.
PwmFile = open(PWM_DEVICE_NAME,O_RDWR);
207 if (OutputInstance.
PwmFile >= 0)
211 OutputInstance.
MotorFile = open(MOTOR_DEVICE_NAME,O_RDWR | O_SYNC);
214 pTmp = (
MOTORDATA*)mmap(0,
sizeof(OutputInstance.
MotorData), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, OutputInstance.
MotorFile, 0);
216 if (pTmp == MAP_FAILED)
236 RESULT Result = FAIL;
238 UBYTE PrgStart = opPROGRAM_START;
242 if (OutputInstance.
PwmFile >= 0)
244 write(OutputInstance.
PwmFile,&PrgStart,1);
261 RESULT Result = FAIL;
271 if (OutputInstance.
PwmFile >= 0)
286 TypeArr[0] = opOUTPUT_SET_TYPE;
287 memcpy(&TypeArr[1], pTypes, 4);
289 if (OutputInstance.
PwmFile >= 0)
291 write(OutputInstance.
PwmFile,TypeArr,
sizeof(TypeArr));
314 if ((Val < 32) && (Val > -32))
316 pStr[Len] = (
DATA8)(Val & 0x0000003F);
325 pStr[Len] = (
DATA8)Val;
336 ((
UBYTE*)pStr)[Len] = (
UBYTE)((Val >> 8) & 0x00FF);
343 ((
UBYTE*)pStr)[Len] = (
UBYTE)(Val & 0x000000FF);
345 ((
UBYTE*)pStr)[Len] = (
UBYTE)((Val >> 8) & 0x000000FF);
347 ((
UBYTE*)pStr)[Len] = (
UBYTE)((Val >> 16) & 0x000000FF);
349 ((
UBYTE*)pStr)[Len] = (
UBYTE)((Val >> 24) & 0x000000FF);
387 if (OutputInstance.
PwmFile >= 0)
389 read(OutputInstance.
PwmFile,BusyReturn,4);
390 sscanf(BusyReturn,
"%u %u",&test,&test2);
410 write(OutputInstance.
MotorFile, &Flags,
sizeof(Flags));
435 PrgStop = (
DATA8)opPROGRAM_STOP;
436 if (OutputInstance.
PwmFile >= 0)
438 write(OutputInstance.
PwmFile,&PrgStop,1);
475 if ((No >= 0) && (No <
OUTPUTS))
484 printf(
" Output %c Disable\r\n",
'A' + No);
490 printf(
" Output %c Enable\r\n",
'A' + No);
498 #ifndef DISABLE_DAISYCHAIN_COM_CALL
503 DaisyBuf[Len++] = opOUTPUT_RESET;
556 ResetArr[0] = opOUTPUT_RESET;
559 if (OutputInstance.
PwmFile >= 0)
561 write(OutputInstance.
PwmFile,ResetArr,
sizeof(ResetArr));
566 #ifndef DISABLE_DAISYCHAIN_COM_CALL
571 DaisyBuf[Len++] = opOUTPUT_RESET;
625 StopArr[0] = (
DATA8)opOUTPUT_STOP;
629 if (OutputInstance.
PwmFile >= 0)
631 write(OutputInstance.
PwmFile,StopArr,
sizeof(StopArr));
636 #ifndef DISABLE_DAISYCHAIN_COM_CALL
641 DaisyBuf[Len++] = opOUTPUT_STOP;
700 SetSpeed[0] = (
DATA8)opOUTPUT_SPEED;
704 if (OutputInstance.
PwmFile >= 0)
706 write(OutputInstance.
PwmFile,SetSpeed,
sizeof(SetSpeed));
711 #ifndef DISABLE_DAISYCHAIN_COM_CALL
716 DaisyBuf[Len++] = opOUTPUT_SPEED;
769 SetPower[0] = (
DATA8)opOUTPUT_POWER;
772 if (OutputInstance.
PwmFile >= 0)
774 write(OutputInstance.
PwmFile,SetPower,
sizeof(SetPower));
779 #ifndef DISABLE_DAISYCHAIN_COM_CALL
784 DaisyBuf[Len++] = opOUTPUT_POWER;
842 StartMotor[0] = (
DATA8)opOUTPUT_START;
844 if (OutputInstance.
PwmFile >= 0)
846 write(OutputInstance.
PwmFile,StartMotor,
sizeof(StartMotor));
848 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
850 if (Nos & (0x01 << Tmp))
859 #ifndef DISABLE_DAISYCHAIN_COM_CALL
864 DaisyBuf[Len++] = opOUTPUT_START;
920 Polarity[0] = (
DATA8)opOUTPUT_POLARITY;
926 if (OutputInstance.
PwmFile >= 0)
928 write(OutputInstance.
PwmFile,Polarity,
sizeof(Polarity));
933 #ifndef DISABLE_DAISYCHAIN_COM_CALL
938 DaisyBuf[Len++] = opOUTPUT_POLARITY;
990 StepPower.
Cmd = opOUTPUT_STEP_POWER;
1000 if (OutputInstance.
PwmFile >= 0)
1002 write(OutputInstance.
PwmFile,(
DATA8*)&(StepPower.
Cmd),
sizeof(StepPower));
1004 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
1007 if (StepPower.
Nos & (0x01 << Tmp))
1016 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1019 DaisyBuf[Len++] = 0;
1020 DaisyBuf[Len++] = 0;
1021 DaisyBuf[Len++] = opOUTPUT_STEP_POWER;
1081 TimePower.
Cmd = opOUTPUT_TIME_POWER;
1091 if (OutputInstance.
PwmFile >= 0)
1093 write(OutputInstance.
PwmFile,(
DATA8*)&(TimePower.
Cmd),
sizeof(TimePower));
1095 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
1098 if (TimePower.
Nos & (0x01 << Tmp))
1107 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1110 DaisyBuf[Len++] = 0;
1111 DaisyBuf[Len++] = 0;
1112 DaisyBuf[Len++] = opOUTPUT_TIME_POWER;
1170 StepSpeed.
Cmd = opOUTPUT_STEP_SPEED;
1189 if (OutputInstance.
PwmFile >= 0)
1191 write(OutputInstance.
PwmFile,(
DATA8*)&(StepSpeed.
Cmd),
sizeof(StepSpeed));
1193 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
1196 if (StepSpeed.
Nos & (0x01 << Tmp))
1205 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1208 DaisyBuf[Len++] = 0;
1209 DaisyBuf[Len++] = 0;
1210 DaisyBuf[Len++] = opOUTPUT_STEP_SPEED;
1227 printf(
"NOT ok txed cOutputStepSpeed\n\r");
1281 TimeSpeed.
Cmd = (
DATA8)opOUTPUT_TIME_SPEED;
1291 if (OutputInstance.
PwmFile >= 0)
1293 write(OutputInstance.
PwmFile,(
DATA8*)&(TimeSpeed.
Cmd),
sizeof(TimeSpeed));
1295 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
1298 if (TimeSpeed.
Nos & (0x01 << Tmp))
1307 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1310 DaisyBuf[Len++] = 0;
1311 DaisyBuf[Len++] = 0;
1312 DaisyBuf[Len++] = opOUTPUT_TIME_SPEED;
1367 StepSync.
Cmd = opOUTPUT_STEP_SYNC;
1376 if (OutputInstance.
PwmFile >= 0)
1378 write(OutputInstance.
PwmFile,(
DATA8*)&(StepSync.
Cmd),
sizeof(StepSync));
1380 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
1383 if (StepSync.
Nos & (0x01 << Tmp))
1392 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1395 DaisyBuf[Len++] = 0;
1396 DaisyBuf[Len++] = 0;
1397 DaisyBuf[Len++] = opOUTPUT_STEP_SYNC;
1452 TimeSync.
Cmd = opOUTPUT_TIME_SYNC;
1461 if (OutputInstance.
PwmFile >= 0)
1463 write(OutputInstance.
PwmFile,(
DATA8*)&(TimeSync.
Cmd),
sizeof(TimeSync));
1465 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
1468 if (TimeSync.
Nos & (0x01 << Tmp))
1477 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1480 DaisyBuf[Len++] = 0;
1481 DaisyBuf[Len++] = 0;
1482 DaisyBuf[Len++] = opOUTPUT_TIME_SYNC;
1565 DATA8 Layer, Tmp, Nos;
1573 char BusyReturn[10];
1583 if (OutputInstance.
PwmFile >= 0)
1585 read(OutputInstance.
PwmFile,BusyReturn,4);
1587 sscanf(BusyReturn,
"%u %u",&test,&test2);
1592 if (Nos & (1 << Tmp))
1595 if (test & (1 << Tmp))
1598 if (OutputInstance.
Owner[Tmp] == Owner)
1615 if (Nos & (1 << Tmp))
1618 if (Bits & (1 << Tmp))
1621 if (OutputInstance.
Owner[Tmp] == Owner)
1657 DATA8 Layer, Nos, Busy = 0;
1662 char BusyReturn[20];
1669 if (OutputInstance.
PwmFile >= 0)
1671 read(OutputInstance.
PwmFile,BusyReturn,10);
1672 sscanf(BusyReturn,
"%u %u",&test,&test2);
1674 if (Nos & (
DATA8)test2)
1717 ClrCnt[0] = opOUTPUT_CLR_COUNT;
1722 if (OutputInstance.
PwmFile >= 0)
1724 write(OutputInstance.
PwmFile, ClrCnt,
sizeof(ClrCnt));
1728 for(Tmp = 0; Tmp <
OUTPUTS; Tmp++)
1730 if (ClrCnt[1] & (1 << Tmp))
1738 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1741 DaisyBuf[Len++] = 0;
1742 DaisyBuf[Len++] = 0;
1743 DaisyBuf[Len++] = opOUTPUT_CLR_COUNT;
RESULT cDaisyDownStreamCmd(DATA8 *pData, DATA8 Length, DATA8 Layer)
void SetDispatchStatus(DSPSTAT DspStat)
Set object (dispatch) status.
UBYTE cDaisyCheckBusyBit(UBYTE Layer, UBYTE PortBits)
void cOutputSetType(void)
opOUTPUT_SET_TYPE byte code
void cOutputTimeSync(void)
opOUTPUT_STEP_SYNC byte code
void ResetDelayCounter(UBYTE Pattern)
SWORD DATA16
VM Type for 2 byte signed value.
void LogErrorNumber(ERR Err)
SLONG DATA32
VM Type for 4 byte signed value.
void cMotorSetBusyFlags(UBYTE Flags)
UWORD OBJID
Object id type.
OUTPUT_GLOBALS * gOutputInstance
UBYTE cOutputPackParam(DATA32 Val, DATA8 *pStr)
void SetObjectIp(IP Ip)
Set current instruction pointer.
Port empty or not available.
void cOutputReset(void)
opOUTPUT_RESET byte code
void * PrimParPointer(void)
Get next encoded parameter from byte code stream.
void cOutputStepSpeed(void)
opOUTPUT_STEP_SPEED byte code
IP GetObjectIp(void)
Get current instruction pointer.
OBJID CallingObjectId(void)
Get calling object id.
IMGDATA * IP
Instruction pointer type.
void cOutputClrCount(void)
opOUTPUT_CLR_COUNT byte code
void cOutputStepPower(void)
opOUTPUT_STEP_POWER byte code
void cOutputStepSync(void)
opOUTPUT_STEP_SYNC byte code
void cOutputRead(void)
opOUTPUT_READ byte code
RESULT cOutputClose(void)
void cOutputPower(void)
opOUTPUT_POWER byte code
Port not empty and type is invalid.
void cOutputPolarity(void)
opOUTPUT_POLARITY byte code
RESULT cDaisyMotorDownStream(DATA8 *pData, DATA8 Length, DATA8 Layer, DATA8 PortField)
DATA8 OutputType[OUTPUTS]
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
void SetPower(UBYTE Port, SLONG Power)
void cOutputStop(void)
opOUTPUT_STOP byte code
void cOutputStart(void)
opOUTPUT_START byte code
void cOutputPrgStop(void)
opOUTPUT_PRG_STOP byte code
#define OUTPUTS
Number of output ports in the system.
void cOutputSetTypes(char *pTypes)
void cOutputTest(void)
opOUTPUT_TEST byte code
void cOutputTimePower(void)
opOUTPUT_TIME_POWER byte code
SBYTE DATA8
VM Type for 1 byte signed value.
void cOutputSpeed(void)
opOUTPUT_SPEED byte code
UBYTE cMotorGetBusyFlags(void)
void cOutputTimeSpeed(void)
opOUTPUT_TIME_SPEED byte code
void cOutputGetCount(void)
opOUTPUT_GET_COUNT byte code
void cOutputReady(void)
opOUTPUT_READY byte code
Break because of waiting for completion.
Dispatcher running (looping)
void setOutputInstance(OUTPUT_GLOBALS *_Instance)
OUTPUT_GLOBALS * getOutputInstance()
MOTORDATA MotorData[OUTPUTS]