111 #ifndef DISABLE_DAISYCHAIN_COM_CALL
114 #include "../../c_memory/source/c_memory.h"
118 #define DEBUG_TRACE_MODE_CHANGE
119 #define DEBUG_C_INPUT_DAISYCHAIN
122 #if (HARDWARE != SIMULATION)
127 #include <sys/mman.h>
128 #include <sys/ioctl.h>
129 #include <sys/stat.h>
131 #ifndef DISABLE_DAISYCHAIN_COM_CALL
132 static DATA8 DaisyBuf[64];
133 static DATA8 ActLayer = 0;
134 static DATA8 MoreLayers = 0;
141 #define snprintf _snprintf
149 gInputInstance = _Instance;
159 #ifndef DISABLE_DAISYCHAIN
166 {
"PORT ERROR" ,
TYPE_ERROR , CONN_ERROR , 0 , 0 , 0 , 4 , 0 , 1 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0,
'f',
"" },
167 {
"NONE" ,
TYPE_NONE , CONN_NONE , 0 , 0 , 0 , 4 , 0 , 1 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0,
'f',
"" },
168 {
"UNKNOWN" ,
TYPE_UNKNOWN , CONN_UNKNOWN , 0 , 1 , 1 , 4 , 0 , 1 , 0.0, 1023.0, 0.0, 100.0, 0.0, 1023.0, 0, 0,
'f',
"" },
175 void cInputPrintLine(
char *pBuffer)
177 printf(
"%s",pBuffer);
180 void cInputShowTypeData(
void)
191 snprintf(Buffer,LINESIZE,
"//! \\page types Known Device Types\r\n");
192 cInputPrintLine(Buffer);
193 snprintf(Buffer,LINESIZE,
"//!\r\n");
194 cInputPrintLine(Buffer);
195 snprintf(Buffer,LINESIZE,
"//! <hr size=\"1\"/>\r\n");
196 cInputPrintLine(Buffer);
197 snprintf(Buffer,LINESIZE,
"//! Following devices are supported (except devices starting with //)\\n\r\n");
198 cInputPrintLine(Buffer);
199 snprintf(Buffer,LINESIZE,
"//! Devices marked with * means that the data is supplied by the device itself\\n\r\n");
200 cInputPrintLine(Buffer);
201 snprintf(Buffer,LINESIZE,
"//! Devices marked with # is not supported in View and Datalog apps\r\n");
202 cInputPrintLine(Buffer);
203 snprintf(Buffer,LINESIZE,
"//!\r\n");
204 cInputPrintLine(Buffer);
205 snprintf(Buffer,LINESIZE,
"//! \\verbatim\r\n");
206 cInputPrintLine(Buffer);
208 cInputPrintLine(Buffer);
209 snprintf(Buffer,LINESIZE,
"// Type Mode Name DataSets Format Figures Decimals Views Conn. Pins RawMin RawMax PctMin PctMax SiMin SiMax Time IdValue Symbol\r\n");
210 cInputPrintLine(Buffer);
211 snprintf(Buffer,LINESIZE,
"// ---- ---- -------- -------- ------ ------- -------- ----- ----- ---- ------- ------- ------ ------ ------- ------- ---- ------- --------\r\n");
212 cInputPrintLine(Buffer);
222 if (Type <= MAX_VALID_TYPE)
227 if (Type != LastType)
230 cInputPrintLine(Buffer);
237 if (Connection == CONN_INPUT_UART)
241 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
"* ");
245 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
"* # ");
250 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
253 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
"%-4u",Type);
255 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
256 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
"%-4u",Mode);
258 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
261 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
264 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
267 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
270 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
273 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
276 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
277 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
"%3u",Connection);
279 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
282 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
285 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
288 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
291 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
294 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
297 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
300 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
303 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
306 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
" ");
314 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
"_");
317 Pos +=
snprintf(&Buffer[Pos],LINESIZE - Pos,
"\r\n");
318 cInputPrintLine(Buffer);
323 cInputPrintLine(Buffer);
325 snprintf(Buffer,LINESIZE,
"//! \\endverbatim\r\n");
326 cInputPrintLine(Buffer);
327 snprintf(Buffer,LINESIZE,
"//! See connection types \\ref connectiontypes \"Conn.\"\r\n");
328 cInputPrintLine(Buffer);
329 snprintf(Buffer,LINESIZE,
"//! \r\n");
330 cInputPrintLine(Buffer);
331 snprintf(Buffer,LINESIZE,
"//! \\n\r\n");
332 cInputPrintLine(Buffer);
338 void Memcpy(
void *pDest,
const void *pSrc,
size_t No)
340 #ifndef DISABLE_AD_WORD_PROTECT
346 if (((No & 3) == 0) && (((
int)pDest & 3) == 0) && (((
int)pSrc & 3) == 0))
348 pLDest = (
ULONG*)pDest;
349 pLSrc = (
ULONG*)pSrc;
360 if (((No & 1) == 0) && (((
int)pDest & 1) == 0) && (((
int)pSrc & 1) == 0))
362 pWDest = (
UWORD*)pDest;
363 pWSrc = (
UWORD*)pSrc;
374 memcpy(pDest,pSrc,No);
378 memcpy(pDest,pSrc,No);
383 IMGDATA CLR_LAYER_CLR_CHANGES[] = { opINPUT_DEVICE,CLR_CHANGES,0,0,opINPUT_DEVICE,CLR_CHANGES,0,1,opINPUT_DEVICE,CLR_CHANGES,0,2,opINPUT_DEVICE,CLR_CHANGES,0,3,opOBJECT_END };
387 IMGDATA CLR_LAYER_INPUT_WRITE[] = { opINPUT_WRITE,0,0,1,DEVCMD_RESET,opINPUT_WRITE,0,1,1,DEVCMD_RESET,opINPUT_WRITE,0,2,1,DEVCMD_RESET,opINPUT_WRITE,0,3,1,DEVCMD_RESET,opOBJECT_END };
420 RESULT Result = FAIL;
422 if ((Device >= 0) && (Device <
DEVICES))
451 RESULT Result = FAIL;
467 if ((*pDevice >= 0) && (*pDevice <
DEVICES))
478 RESULT Result = FAIL;
482 if ((Type >= 0) && (Type < (MAX_DEVICE_TYPE + 1)) && (Mode >= 0) && (Mode < MAX_DEVICE_MODES))
486 while ((Index < InputInstance.
IicDeviceTypes) && (Result != BUSY))
532 printf(
"Iic error %d: m=%d IIC\r\n",Type,Mode);
541 RESULT Result = FAIL;
545 (*IicStr).SetupLng = 0;
546 (*IicStr).SetupString = 0;
547 (*IicStr).PollLng = 0;
548 (*IicStr).PollString = 0;
549 (*IicStr).ReadLng = 0;
551 if ((Type >= 0) && (Type < (MAX_DEVICE_TYPE + 1)) && (Mode >= 0) && (Mode < MAX_DEVICE_MODES))
561 (*IicStr).Type = Type;
562 (*IicStr).Mode = Mode;
583 RESULT Result = FAIL;
588 if ((Type >= 0) && (Type < (MAX_DEVICE_TYPE + 1)) && (Mode >= 0) && (Mode < MAX_DEVICE_MODES))
591 while ((Index < InputInstance.
MaxDeviceTypes) && (Result != BUSY))
597 *ppPlace = &InputInstance.
TypeData[Index];
629 printf(
"Type error %d: m=%d c=%d n=%s\r\n",Type,Mode,Connection,pName);
638 RESULT Result = FAIL;
643 char Manufacturer[256];
644 char SensorType[256];
646 unsigned int Connection;
648 unsigned int DataSets;
650 unsigned int Figures;
651 unsigned int Decimals;
655 unsigned int IdValue;
656 unsigned int SetupLng;
657 unsigned int SetupString;
658 unsigned int PollLng;
659 unsigned int PollString;
666 pFile = fopen (pFilename,
"r");
671 Str = fgets(Buf,255,pFile);
675 if ((Buf[0] !=
'/') && (Buf[0] !=
'*'))
677 Count = sscanf(Buf,
"%u %u %s %u %u %u %u %u %u %x %f %f %f %f %f %f %u %u %s",&Type,&Mode,Name,&DataSets,&Format,&Figures,&Decimals,&Views,&Connection,&Pins,&Tmp.
RawMin,&Tmp.
RawMax,&Tmp.
PctMin,&Tmp.
PctMax,&Tmp.
SiMin,&Tmp.
SiMax,&Time,&IdValue,Symbol);
701 if (Name[Count] ==
'_')
703 (*pTypes).
Name[Count] =
' ';
707 (*pTypes).Name[Count] = Name[Count];
711 (*pTypes).Name[Count] = 0;
713 if (Symbol[0] ==
'_')
715 (*pTypes).Symbol[0] = 0;
722 if (Symbol[Count] ==
'_')
724 (*pTypes).Symbol[Count] =
' ';
728 (*pTypes).Symbol[Count] = Symbol[Count];
732 (*pTypes).Symbol[Count] = 0;
740 Count = sscanf(Buf,
"%u %u %s %u %u %u %u %u %u %x %f %f %f %f %f %f %u %u %s %s %s %u %X %u %X %d",&Type,&Mode,Name,&DataSets,&Format,&Figures,&Decimals,&Views,&Connection,&Pins,&Tmp.
RawMin,&Tmp.
RawMax,&Tmp.
PctMin,&Tmp.
PctMax,&Tmp.
SiMin,&Tmp.
SiMax,&Time,&IdValue,Symbol,Manufacturer,SensorType,&SetupLng,&SetupString,&PollLng,&PollString,&ReadLng);
764 char PrgNameBuf[255];
766 UBYTE TypeDataFound = 0;
770 while (Index < (MAX_DEVICE_TYPE + 1))
778 while ((Index < (InputInstance.
MaxDeviceTypes + 1)) && (TypeDefault[Index].
Name[0] != 0))
780 InputInstance.
TypeData[Index] = TypeDefault[Index];
797 snprintf(PrgNameBuf,vmFILENAMESIZE,
"%s/%s%s",vmSETTINGS_DIR,TYPEDATE_FILE_NAME,
EXT_CONFIG);
806 snprintf(PrgNameBuf,vmFILENAMESIZE,
"%s/%s%02d%s",vmSETTINGS_DIR,TYPEDATE_FILE_NAME,Index,
EXT_CONFIG);
831 if (InputInstance.
IicFile >= MIN_HANDLE)
834 if (WrLng > MAX_DEVICE_DATALENGTH)
836 WrLng = MAX_DEVICE_DATALENGTH;
838 if (RdLng > MAX_DEVICE_DATALENGTH)
840 RdLng = MAX_DEVICE_DATALENGTH;
845 if (Time < MIN_IIC_REPEAT_TIME)
847 Time = MIN_IIC_REPEAT_TIME;
849 if (Time > MAX_IIC_REPEAT_TIME)
851 Time = MAX_IIC_REPEAT_TIME;
878 #ifndef DISABLE_DAISYCHAIN
897 RESULT Result = FAIL;
903 IdValue =
CtoV((*InputInstance.
pAnalog).InPin1[Device]);
909 if (Tmp >= IN1_ID_HYSTERESIS)
911 if ((IdValue >= (Tmp - IN1_ID_HYSTERESIS)) && (IdValue < (Tmp + IN1_ID_HYSTERESIS)))
950 RESULT Result = FAIL;
962 if (Tmp >= OUT5_ID_HYSTERESIS)
964 if ((IdValue >= (Tmp - OUT5_ID_HYSTERESIS)) && (IdValue < (Tmp + OUT5_ID_HYSTERESIS)))
990 RESULT Result = FAIL;
1004 *pTypeIndex = Index;
1033 for (TmpPrgId = 0;TmpPrgId < MAX_PROGRAMS;TmpPrgId++)
1044 char Buf[
INPUTS * 2 + 1];
1087 (*InputInstance.
pAnalog).Updated[Device] = 0;
1100 if (InputInstance.
IicFile >= MIN_HANDLE)
1108 for (Index = 0;Index <
INPUTS;Index++)
1119 if (InputInstance.
DcmFile >= MIN_HANDLE)
1121 write(InputInstance.
DcmFile,Buf,INPUTS);
1124 for (Index = 0;Index <
INPUTS;Index++)
1133 if (InputInstance.
UartFile >= MIN_HANDLE)
1137 if (InputInstance.
IicFile >= MIN_HANDLE)
1142 #ifdef DEBUG_TRACE_MODE_CHANGE
1177 #ifdef DEBUG_TRACE_MODE_CHANGE
1198 #ifndef DISABLE_DAISYCHAIN
1209 #ifdef DEBUG_TRACE_MODE_CHANGE
1213 #ifdef ENABLE_STATUS_TEST
1222 #ifdef ENABLE_STATUS_TEST
1240 #ifdef DEBUG_TRACE_MODE_CHANGE
1259 char PrgNameBuf[vmFILENAMESIZE];
1261 snprintf(PrgNameBuf,vmFILENAMESIZE,
"%s/%s%s",vmSETTINGS_DIR,vmCALDATA_FILE_NAME,vmEXT_CONFIG);
1262 File = open(PrgNameBuf,O_RDONLY);
1263 if (File >= MIN_HANDLE)
1265 if (read(File,(
UBYTE*)&InputInstance.
Calib,
sizeof(InputInstance.
Calib)) !=
sizeof(InputInstance.
Calib))
1277 for (Type = 0;Type < (MAX_DEVICE_TYPE);Type++)
1279 for (Mode = 0;Mode < MAX_DEVICE_MODES;Mode++)
1291 char PrgNameBuf[vmFILENAMESIZE];
1293 snprintf(PrgNameBuf,vmFILENAMESIZE,
"%s/%s%s",vmSETTINGS_DIR,vmCALDATA_FILE_NAME,vmEXT_CONFIG);
1294 File = open(PrgNameBuf,O_CREAT | O_WRONLY | O_TRUNC,SYSPERMISSIONS);
1295 if (File >= MIN_HANDLE)
1303 #ifndef DISABLE_OLD_COLOR
1308 #define SENSOR_RESOLUTION 1023L
1312 #define AD_MAX 2703L
1315 #define COLORSENSORBGMIN (214/(AD_FS/AD_MAX))
1316 #define COLORSENSORMIN (1L/(AD_FS/AD_MAX))
1317 #define COLORSENSORMAX ((AD_MAX * AD_FS)/3300)
1318 #define COLORSENSORPCTDYN (UBYTE)(((COLORSENSORMAX - COLORSENSORMIN) * 100L)/AD_MAX)
1319 #define COLORSENSORBGPCTDYN (UBYTE)(((COLORSENSORMAX - COLORSENSORBGMIN) * 100L)/AD_MAX)
1323 if (*pRawVal >= ZeroPointOffset)
1325 *pRawVal -= ZeroPointOffset;
1332 *pRawVal = (*pRawVal * 100)/PctFullScale;
1337 if (
TRUE == InvStatus)
1348 if ((pC->ADRaw[
BLANK]) < pC->CalLimits[1])
1354 if ((pC->ADRaw[
BLANK]) < pC->CalLimits[0])
1365 if ((pC->ADRaw[
RED]) > (pC->ADRaw[
BLANK]))
1367 pNewVals[
RED] = (
UWORD)(((
ULONG)((pC->ADRaw[
RED]) - (pC->ADRaw[
BLANK])) * (pC->Calibration[CalRange][
RED])) >> 16);
1370 pNewVals[
GREEN] = 0;
1377 if ((pC->ADRaw[
BLUE]) > (pC->ADRaw[
BLANK]))
1384 (pNewVals[
BLANK]) = (
UWORD)(((
ULONG)(pNewVals[BLANK]) * (pC->Calibration[CalRange][
BLANK])) >> 16);
1397 if (((pC->SensorRaw[
RED]) > (pC->SensorRaw[
BLUE] )) &&
1398 ((pC->SensorRaw[
RED]) > (pC->SensorRaw[
GREEN])))
1402 if (((pC->SensorRaw[
RED]) < 65) ||
1403 (((pC->SensorRaw[
BLANK]) < 40) && ((pC->SensorRaw[
RED]) < 110)))
1409 if (((((pC->SensorRaw[
BLUE]) >> 2) + ((pC->SensorRaw[
BLUE]) >> 3) + (pC->SensorRaw[
BLUE])) < (pC->SensorRaw[
GREEN])) &&
1410 ((((pC->SensorRaw[
GREEN]) << 1)) > (pC->SensorRaw[
RED])))
1417 if ((((pC->SensorRaw[
GREEN]) << 1) - ((pC->SensorRaw[
GREEN]) >> 2)) < (pC->SensorRaw[
RED]))
1425 if ((((pC->SensorRaw[
BLUE]) < 70) ||
1426 ((pC->SensorRaw[
GREEN]) < 70)) ||
1427 (((pC->SensorRaw[
BLANK]) < 140) && ((pC->SensorRaw[
RED]) < 140)))
1443 if ((pC->SensorRaw[
GREEN]) > (pC->SensorRaw[
BLUE]))
1448 if (((pC->SensorRaw[
GREEN]) < 40) ||
1449 (((pC->SensorRaw[
BLANK]) < 30) && ((pC->SensorRaw[
GREEN]) < 70)))
1455 if ((((pC->SensorRaw[
BLUE]) << 1)) < (pC->SensorRaw[
RED]))
1461 if ((((pC->SensorRaw[
RED]) + ((pC->SensorRaw[
RED])>>2)) < (pC->SensorRaw[
GREEN])) ||
1462 (((pC->SensorRaw[
BLUE]) + ((pC->SensorRaw[
BLUE])>>2)) < (pC->SensorRaw[
GREEN])))
1468 if ((((pC->SensorRaw[
RED]) < 70) ||
1469 ((pC->SensorRaw[
BLUE]) < 70)) ||
1470 (((pC->SensorRaw[
BLANK]) < 140) && ((pC->SensorRaw[
GREEN]) < 140)))
1488 if (((pC->SensorRaw[
BLUE]) < 48) ||
1489 (((pC->SensorRaw[
BLANK]) < 25) && ((pC->SensorRaw[
BLUE]) < 85)))
1495 if ((((((pC->SensorRaw[
RED]) * 48) >> 5) < (pC->SensorRaw[
BLUE])) &&
1496 ((((pC->SensorRaw[
GREEN]) * 48) >> 5) < (pC->SensorRaw[
BLUE])))
1498 (((((pC->SensorRaw[
RED]) * 58) >> 5) < (pC->SensorRaw[
BLUE])) ||
1499 ((((pC->SensorRaw[
GREEN]) * 58) >> 5) < (pC->SensorRaw[
BLUE]))))
1507 if ((((pC->SensorRaw[
RED]) < 60) ||
1508 ((pC->SensorRaw[
GREEN]) < 60)) ||
1509 (((pC->SensorRaw[
BLANK]) < 110) && ((pC->SensorRaw[
BLUE]) < 120)))
1515 if ((((pC->SensorRaw[
RED]) + ((pC->SensorRaw[
RED]) >> 3)) < (pC->SensorRaw[
BLUE])) ||
1516 (((pC->SensorRaw[
GREEN]) + ((pC->SensorRaw[
GREEN]) >> 3)) < (pC->SensorRaw[
BLUE])))
1535 #ifndef DISABLE_DAISYCHAIN
1539 RESULT Result = FAIL;
1556 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).NxtCol[Device].ADRaw[
BLANK],(
size_t)2);
1564 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).NxtCol[Device].ADRaw[
RED],(
size_t)2);
1572 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).NxtCol[Device].ADRaw[
GREEN],(
size_t)2);
1580 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).NxtCol[Device].ADRaw[
BLUE],(
size_t)2);
1588 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).NxtCol[Device].SensorRaw[0],(
size_t)(
COLORS * 2));
1619 Result = (*InputInstance.
pAnalog).NxtCol[Device].ADRaw[
BLANK];
1626 Result = (*InputInstance.
pAnalog).NxtCol[Device].ADRaw[
RED];
1633 Result = (*InputInstance.
pAnalog).NxtCol[Device].ADRaw[
GREEN];
1640 Result = (*InputInstance.
pAnalog).NxtCol[Device].ADRaw[
BLUE];
1649 Result = (
DATAF)(*InputInstance.
pAnalog).NxtCol[Device].SensorRaw[Index];
1663 #ifndef DISABLE_DAISYCHAIN
1754 RESULT Result = FAIL;
1761 if ((InputInstance.
DeviceType[Device] > 0) && (InputInstance.
DeviceType[Device] <= MAX_VALID_TYPE))
1768 #ifdef DEBUG_TRACE_DAISYCHAIN
1769 printf(
"c_input cInputSetDeviceType: L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,Type,Mode);
1775 #ifdef DEBUG_TRACE_DAISYCHAIN
1776 printf(
"c_input cInputSetDeviceType: FAIL L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,Type,Mode);
1786 RESULT Result = FAIL;
1787 #ifdef DEBUG_TRACE_DAISYCHAIN
1791 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1806 #ifdef DEBUG_TRACE_DAISYCHAIN
1807 pType = (
TYPES*)pInfo;
1811 printf(
"c_com cComSetDeviceInfo: l=%-2d N=%s\r\n",Length,(*pType).Name);
1817 printf(
"c_com cComSetDeviceInfo: BUSY l=%-2d N=%s\r\n",Length,(*pType).Name);
1821 printf(
"c_com cComSetDeviceInfo: FAIL l=%-2d N=%s\r\n",Length,(*pType).Name);
1832 RESULT Result = FAIL;
1833 #ifdef DEBUG_TRACE_DAISYCHAIN
1837 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1843 #ifdef DEBUG_TRACE_DAISYCHAIN
1846 pType = (
TYPES*)pInfo;
1847 printf(
"c_com cComGetDeviceInfo: C=%-3d N=%s\r\n",(*pType).Connection,(*pType).Name);
1857 RESULT Result = FAIL;
1859 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1865 #ifdef DEBUG_TRACE_DAISYCHAIN
1868 printf(
"c_com cComSetDeviceType: L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,Type,Mode);
1874 printf(
"c_com cComSetDeviceType: BUSY L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,Type,Mode);
1878 printf(
"c_com cComSetDeviceType: FAIL L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,Type,Mode);
1889 RESULT Result = FAIL;
1891 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1894 #ifdef DEBUG_TRACE_DAISYCHAIN
1897 printf(
"c_com cComGetDeviceData: L=%-2d P=%-2d T=%-3d M=%d 0x%02X\r\n",Layer,Port,*pType,*pMode,*pData);
1903 printf(
"c_com cComGetDeviceData: BUSY L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,*pType,*pMode);
1907 printf(
"c_com cComGetDeviceData: FAIL L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,*pType,*pMode);
1922 RESULT Result = FAIL;
1924 #ifndef DISABLE_DAISYCHAIN_COM_CALL
1941 #ifdef DEBUG_C_INPUT_DAISYCHAIN
1944 printf(
"c_com cInputGetDeviceData: L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,*pType,*pMode);
1950 printf(
"c_com cInputGetDeviceData: BUSY L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,*pType,*pMode);
1954 printf(
"c_com cInputGetDeviceData: FAIL L=%-2d P=%-2d T=%-3d M=%d\r\n",Layer,Port,*pType,*pMode);
1965 #ifdef DEBUG_C_INPUT_FAST_DATALOG
1966 #ifndef DISABLE_FAST_DATALOG_BUFFER
1973 RESULT Result = FAIL;
1975 #ifndef DISABLE_FAST_DATALOG_BUFFER
1983 #ifdef DEBUG_C_INPUT_DAISYCHAIN
1984 printf(
"c_input cInputGetDeviceData D=%-3d L=%d P=%-2d l=%-2d\r\n",Device,Layer,Port,Length);
1987 if (Length >= MAX_DEVICE_DATALENGTH)
1990 memset(pData,0,(
size_t)Length);
2004 if ((Time < 0) || (Time > DEVICE_LOGBUF_SIZE))
2012 #ifndef DISABLE_FAST_DATALOG_BUFFER
2014 Pointer = (*InputInstance.
pUart).Actual[Port];
2015 InPointer = (*InputInstance.
pUart).LogIn[Port];
2018 #ifdef DEBUG_C_INPUT_DATALOG
2019 printf(
"c_input cInputGetDeviceData Act=%-4d In=%-4d Out=%-4d Time=%-4d ",(*InputInstance.
pUart).Actual[Port],(*InputInstance.
pUart).LogIn[Port],*pInit,Time);
2022 if ((*pInit < 0) || (*pInit > DEVICE_LOGBUF_SIZE))
2025 (*InputInstance.
pUart).Repeat[Port][*pInit] = 0;
2026 #ifdef DEBUG_C_INPUT_FAST_DATALOG
2036 #ifdef DEBUG_C_INPUT_FAST_DATALOG
2039 if ((Port == 0) && ((*InputInstance.
pUart).Repeat[Port][*pInit] > 1))
2041 printf(
"C=%-5d A=%-4d I=%-4d P=%-4d O=%-3d N=%-3d R=%-3d \r\n",Cnt,(*InputInstance.
pUart).Actual[Port],(*InputInstance.
pUart).LogIn[Port],Pointer,Old,New,(*InputInstance.
pUart).Repeat[Port][*pInit]);
2046 while ((Time) && ((*InputInstance.
pUart).Repeat[Port][Pointer] > 1))
2048 ((*InputInstance.
pUart).Repeat[Port][Pointer])--;
2051 while ((Time) && (Pointer != InPointer))
2054 if (++Pointer >= DEVICE_LOGBUF_SIZE)
2059 if (Pointer != InPointer)
2066 #ifdef DEBUG_C_INPUT_FAST_DATALOG
2067 if ((Port == 0) && (TmpTime >= 1))
2069 New = (*InputInstance.
pUart).Raw[Device][Pointer][0];
2070 if ((New < (Old - TmpTime)) || (New > (Old + TmpTime)))
2072 if ((New != 0) && ((*InputInstance.
pUart).Repeat[Port][*pInit]))
2074 printf(
"C=%-5d A=%-4d I=%-4d P=%-4d O=%-3d N=%-3d R=%-3d ",Cnt,(*InputInstance.
pUart).Actual[Port],InPointer,Pointer,Old,New,(*InputInstance.
pUart).Repeat[Port][*pInit]);
2085 #ifdef DEBUG_C_INPUT_DATALOG
2086 printf(
"Pointer=%-4d\r\n",Pointer);
2090 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pUart).Raw[Device][Pointer],(
size_t)UART_DATA_LENGTH);
2093 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pUart).Raw[Device],UART_DATA_LENGTH);
2103 #ifndef DISABLE_FAST_DATALOG_BUFFER
2105 Pointer = (*InputInstance.
pIic).Actual[Port];
2106 InPointer = (*InputInstance.
pIic).LogIn[Port];
2109 #ifdef DEBUG_C_INPUT_DATALOG
2110 printf(
"c_input cInputGetDeviceData Act=%-4d In=%-4d Out=%-4d Time=%-4d ",(*InputInstance.
pIic).Actual[Port],(*InputInstance.
pIic).LogIn[Port],*pInit,Time);
2113 if ((*pInit < 0) || (*pInit > DEVICE_LOGBUF_SIZE))
2116 (*InputInstance.
pIic).Repeat[Port][*pInit] = 0;
2117 #ifdef DEBUG_C_INPUT_FAST_DATALOG
2127 while ((Time) && ((*InputInstance.
pIic).Repeat[Port][Pointer] > 1))
2129 ((*InputInstance.
pIic).Repeat[Port][Pointer])--;
2132 while ((Time) && (Pointer != InPointer))
2135 if (++Pointer >= DEVICE_LOGBUF_SIZE)
2140 if (Pointer != InPointer)
2147 #ifdef DEBUG_C_INPUT_FAST_DATALOG
2151 New = (
UWORD)(*InputInstance.
pIic).Raw[Device][Pointer][0];
2152 New += (
UWORD)(*InputInstance.
pIic).Raw[Device][Pointer][1] << 8;
2153 printf(
"C=%-5d A=%-4d I=%-4d P=%-4d O=%-5d N=%-5d R=%-3d\r\n ",Cnt,(*InputInstance.
pIic).Actual[Port],InPointer,Pointer,Old,New,(*InputInstance.
pIic).Repeat[Port][*pInit]);
2159 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pIic).Raw[Device][Pointer],(
size_t)IIC_DATA_LENGTH);
2162 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pIic).Raw[Device],IIC_DATA_LENGTH);
2172 #ifndef DISABLE_FAST_DATALOG_BUFFER
2176 Pointer = (*InputInstance.
pAnalog).Actual[Port];
2177 InPointer = (*InputInstance.
pAnalog).LogIn[Port];
2178 #ifdef DEBUG_C_INPUT_DATALOG
2179 printf(
"c_input cInputGetDeviceData Act=%-4d In=%-4d Out=%-4d Time=%-4d ",(*InputInstance.
pAnalog).Actual[Port],(*InputInstance.
pAnalog).LogIn[Port],*pInit,Time);
2182 if ((*pInit < 0) || (*pInit > DEVICE_LOGBUF_SIZE))
2189 while ((Time) && (Pointer != InPointer))
2192 if (++Pointer >= DEVICE_LOGBUF_SIZE)
2197 if (Pointer != InPointer)
2205 #ifdef DEBUG_C_INPUT_DATALOG
2206 printf(
"Pointer=%-4d\r\n",Pointer);
2214 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).Pin6[Device][Pointer],(
size_t)2);
2225 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).InPin6[Device],(
size_t)2);
2235 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).InPin6[Device],(
size_t)2);
2242 #ifndef DISABLE_OLD_COLOR
2252 #ifndef DISABLE_FAST_DATALOG_BUFFER
2256 Pointer = (*InputInstance.
pAnalog).Actual[Port];
2257 InPointer = (*InputInstance.
pAnalog).LogIn[Port];
2258 #ifdef DEBUG_C_INPUT_DATALOG
2259 printf(
"c_input cInputGetDeviceData Act=%-4d In=%-4d Out=%-4d Time=%-4d ",(*InputInstance.
pAnalog).Actual[Port],(*InputInstance.
pAnalog).LogIn[Port],*pInit,Time);
2262 if ((*pInit < 0) || (*pInit > DEVICE_LOGBUF_SIZE))
2269 while ((Time) && (Pointer != InPointer))
2272 if (++Pointer >= DEVICE_LOGBUF_SIZE)
2277 if (Pointer != InPointer)
2285 #ifdef DEBUG_C_INPUT_DATALOG
2286 printf(
"Pointer=%-4d\r\n",Pointer);
2295 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).Pin1[Device][Pointer],(
size_t)2);
2306 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).InPin1[Device],(
size_t)2);
2316 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).InPin1[Device],(
size_t)2);
2324 #ifndef DISABLE_FAST_DATALOG_BUFFER
2327 Pointer = (*InputInstance.
pAnalog).Actual[Port];
2328 InPointer = (*InputInstance.
pAnalog).LogIn[Port];
2329 #ifdef DEBUG_C_INPUT_DATALOG
2330 printf(
"c_input cInputGetDeviceData Act=%-4d In=%-4d Out=%-4d Time=%-4d ",(*InputInstance.
pAnalog).Actual[Port],*pInit,Time);
2333 if ((*pInit < 0) || (*pInit > DEVICE_LOGBUF_SIZE))
2340 while ((Time) && (Pointer != InPointer))
2344 if (++Pointer >= DEVICE_LOGBUF_SIZE)
2352 #ifdef DEBUG_C_INPUT_DATALOG
2353 printf(
"Pointer=%-4d\r\n",Pointer);
2355 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).Pin1[Device][Pointer],(
size_t)2);
2359 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).InPin1[Device],(
size_t)2);
2362 Memcpy((
void*)pData,(
const void*)&(*InputInstance.
pAnalog).InPin1[Device],(
size_t)2);
2421 #ifdef DEBUG_C_INPUT_DAISYCHAIN
2422 printf(
"c_input cInputReadDeviceRaw: D=%-3d I=%d B=%d\r\n",Device,Index,InputInstance.
DeviceData[Device].
DevStatus);
2428 pData = InputInstance.
Data;
2431 if (
cInputGetData(Layer,Port,Time,pInit,MAX_DEVICE_DATALENGTH,&Type,&Mode,(
DATA8*)pData) == OK)
2435 if (Index < DataSets)
2455 if ((Type == 99) && (Mode == 7) && (Index == 4))
2500 #ifdef DEBUG_C_INPUT_DAISYCHAIN
2501 printf(
"c_input cInputReadDeviceRaw: D=%-3d B=%d\r\n",Device,InputInstance.
DeviceData[Device].
DevStatus);
2503 if ((Device >= 0) && (Device <
DEVICES) && (Index >= 0) && (Index < MAX_DEVICE_DATASETS))
2522 pResult = (
void*)&(*InputInstance.
pUart).Raw[Device];
2525 if (Index < DataSets)
2578 #ifndef DISABLE_OLD_COLOR
2647 if (InputInstance.
DeviceType[Device] != Type)
2659 Byte = (
UBYTE)DataF;
2660 Word = (
UWORD)DataF;
2662 #ifndef DISABLE_FAST_DATALOG_BUFFER
2663 (*InputInstance.
pAnalog).Actual[Device] = 0;
2666 (*InputInstance.
pIic).Raw[Device][(*InputInstance.
pAnalog).Actual[Device]][0] = Byte;
2667 (*InputInstance.
pIic).Raw[Device][(*InputInstance.
pAnalog).Actual[Device]][1] = 0;
2671 (*InputInstance.
pIic).Raw[Device][(*InputInstance.
pAnalog).Actual[Device]][0] = (
UBYTE)Word;
2672 (*InputInstance.
pIic).Raw[Device][(*InputInstance.
pAnalog).Actual[Device]][1] = (
UBYTE)(Word >> 8);
2678 (*InputInstance.
pIic).Raw[Device][0] = Byte;
2679 (*InputInstance.
pIic).Raw[Device][1] = 0;
2683 (*InputInstance.
pIic).Raw[Device][0] = (
UBYTE)Word;
2684 (*InputInstance.
pIic).Raw[Device][1] = (
UBYTE)(Word >> 8);
2691 #ifndef DISABLE_FAST_DATALOG_BUFFER
2692 (*InputInstance.
pAnalog).Actual[Device] = 0;
2693 (*InputInstance.
pAnalog).LogIn[Device] = 0;
2697 (*InputInstance.
pAnalog).Pin6[Device][(*InputInstance.
pAnalog).Actual[Device]] = (
DATA16)DataF;
2702 (*InputInstance.
pAnalog).Pin1[Device][(*InputInstance.
pAnalog).Actual[Device]] = (
DATA16)DataF;
2724 if (InputInstance.
DeviceType[Device] != Type)
2764 if ((Type > 0) && (Type < (MAX_DEVICE_TYPE + 1)) && (Mode >= 0) && (Mode < MAX_DEVICE_MODES))
2768 Min = InputInstance.
Calib[Type][Mode].
Min;
2769 Max = InputInstance.
Calib[Type][Mode].
Max;
2783 Result = (
DATA8)Pct;
2811 if ((Type > 0) && (Type < (MAX_DEVICE_TYPE + 1)) && (Mode >= 0) && (Mode < MAX_DEVICE_MODES))
2815 Min = InputInstance.
Calib[Type][Mode].
Min;
2816 Max = InputInstance.
Calib[Type][Mode].
Max;
2824 if ((Connection == CONN_NXT_DUMB) || (Connection == CONN_INPUT_DUMB) || (Connection == CONN_OUTPUT_DUMB) || (Connection == CONN_OUTPUT_TACHO))
2847 RESULT Result = BUSY;
2851 if (InputInstance.
UartFile >= MIN_HANDLE)
2857 if (InputInstance.
TmpMode[Port] > 0)
2860 InputInstance.
TmpMode[Port]--;
2887 #ifndef DISABLE_DAISYCHAIN
2892 InputInstance.
TmpMode[Port]++;
2907 (*InputInstance.
pUart).Status[Port] &= ~UART_PORT_CHANGED;
2914 if (!((*InputInstance.
pUart).Status[Port] & UART_PORT_CHANGED))
2927 RESULT Result = BUSY;
2932 if (InputInstance.
IicFile >= MIN_HANDLE)
2938 if ((*InputInstance.
pIic).Changed[Port])
2945 Index = IIC_NAME_LENGTH;
2951 Index = IIC_NAME_LENGTH;
3002 RESULT Result = BUSY;
3005 #ifndef DISABLE_DAISYCHAIN
3017 for (Device = 0;Device <
DEVICES;Device++)
3020 if ((Device >= 0) && (Device <
INPUTS))
3031 InputInstance.
TmpMode[Device] = MAX_DEVICE_MODES;
3051 if ((*InputInstance.
pAnalog).Updated[Device])
3078 #ifndef DISABLE_DAISYCHAIN
3084 if ((Type > 0) && (Type <= MAX_VALID_TYPE) && (Result != FAIL))
3094 if (InputInstance.
DeviceType[Device] != Type)
3126 BufPrint(
'p',
"D=%-2d M=%d OK\r\n",(
int)Device,InputInstance.
DeviceMode[Device]);
3148 #ifndef DISABLE_DAISYCHAIN
3158 #ifdef DEBUG_TRACE_DAISYCHAIN
3159 printf(
"c_input cInputDcmUpdate: NEW T=%-3d M=%d C=%-3d N=%s\r\n",Tmp.
Type,Tmp.
Mode,Tmp.
Connection,Tmp.
Name);
3162 #ifdef DEBUG_TRACE_DAISYCHAIN
3165 printf(
"c_input cInputDcmUpdate: KNOWN T=%-3d M=%d C=%-3d N=%s\r\n",Tmp.
Type,Tmp.
Mode,Tmp.
Connection,Tmp.
Name);
3181 if (InputInstance.
TypeData[Index].
Type <= MAX_VALID_TYPE)
3189 #ifdef ENABLE_STATUS_TEST
3193 #ifdef ENABLE_STATUS_TEST
3221 #ifdef ENABLE_STATUS_TEST
3261 InputInstance.
DeviceData[Device].Timer += Time;
3267 Inc = (Max - Min) / (
DATAF)100;
3279 if (InputInstance.
DeviceData[Device].Timer >= Timeout)
3293 if (Inc >= (
DATAF)0)
3324 if (Inc >= (
DATAF)0)
3358 #ifndef DISABLE_BUMBED
3366 #ifndef DISABLE_BUMBED
3374 Value = (
DATAF)(*InputInstance.
pAnalog).InPin1[Device];
3378 Value = (
DATAF)(*InputInstance.
pAnalog).InPin6[Device];
3383 if (Diff >= (
DATAF)500)
3387 if (Diff <= (
DATAF)-500)
3403 cInputSimulate(Time,0,CONN_UNKNOWN,2);
3404 cInputSimulate(Time,1,CONN_UNKNOWN,3);
3405 cInputSimulate(Time,2,CONN_UNKNOWN,1);
3406 cInputSimulate(Time,3,CONN_UNKNOWN,4);
3407 cInputSimulate(Time,16,CONN_UNKNOWN,7);
3408 cInputSimulate(Time,17,CONN_UNKNOWN,7);
3409 cInputSimulate(Time,18,CONN_UNKNOWN,8);
3410 cInputSimulate(Time,19,CONN_UNKNOWN,8);
3437 InputInstance.
pUart = &InputInstance.
Uart;
3439 InputInstance.
pIic = &InputInstance.
Iic;
3441 InputInstance.
AdcFile = open(ANALOG_DEVICE_NAME,O_RDWR | O_SYNC);
3442 InputInstance.
UartFile = open(UART_DEVICE_NAME,O_RDWR | O_SYNC);
3443 InputInstance.
DcmFile = open(DCM_DEVICE_NAME,O_RDWR | O_SYNC);
3444 InputInstance.
IicFile = open(IIC_DEVICE_NAME,O_RDWR | O_SYNC);
3447 if (InputInstance.
AdcFile >= MIN_HANDLE)
3449 pAdcTmp = (ANALOG*)mmap(0,
sizeof(ANALOG), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, InputInstance.
AdcFile, 0);
3451 if (pAdcTmp == MAP_FAILED)
3461 InputInstance.
pAnalog = pAdcTmp;
3474 if (InputInstance.
UartFile >= MIN_HANDLE)
3476 pUartTmp = (UART*)mmap(0,
sizeof(UART), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, InputInstance.
UartFile, 0);
3478 if (pUartTmp == MAP_FAILED)
3488 InputInstance.
pUart = pUartTmp;
3501 if (InputInstance.
IicFile >= MIN_HANDLE)
3503 pIicTmp = (IIC*)mmap(0,
sizeof(UART), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, InputInstance.
IicFile, 0);
3505 if (pIicTmp == MAP_FAILED)
3515 InputInstance.
pIic = pIicTmp;
3531 for (Tmp = 0;Tmp <
DEVICES;Tmp++)
3533 for (Set = 0;Set < MAX_DEVICE_DATASETS;Set++)
3544 #ifndef DISABLE_BUMBED
3552 InputInstance.
TmpMode[Tmp] = MAX_DEVICE_MODES;
3555 for (TmpPrgId = 0;TmpPrgId < MAX_PROGRAMS;TmpPrgId++)
3566 RESULT Result = FAIL;
3576 RESULT Result = FAIL;
3586 RESULT Result = FAIL;
3590 if (InputInstance.
AdcFile >= MIN_HANDLE)
3592 munmap(InputInstance.
pAnalog,
sizeof(ANALOG));
3596 if (InputInstance.
UartFile >= MIN_HANDLE)
3598 munmap(InputInstance.
pUart,
sizeof(UART));
3602 if (InputInstance.
IicFile >= MIN_HANDLE)
3604 munmap(InputInstance.
pIic,
sizeof(IIC));
3608 if (InputInstance.
DcmFile >= MIN_HANDLE)
3619 free((
void*)InputInstance.
TypeData);
3694 while ((Count < Length) && (Count <
DEVICES))
3696 pDevices[Count] = InputInstance.
DeviceType[Count];
3702 pDevices[Count] = 0;
3894 DATA8 *pDestination;
3920 #ifndef DISABLE_DAISYCHAIN_COM_CALL
3927 if ((Cmd != CAL_MINMAX) && (Cmd != CAL_MIN) && (Cmd != CAL_MAX) && (Cmd != CAL_DEFAULT) && (Cmd != CLR_ALL) && (Cmd != STOP_ALL))
3942 if ((Type > 0) && (Type < (MAX_DEVICE_TYPE + 1)) && (Mode >= 0) && (Mode < MAX_DEVICE_MODES))
3944 InputInstance.
Calib[Type][Mode].
Min = Min;
3945 InputInstance.
Calib[Type][Mode].
Max = Max;
3956 if ((Type > 0) && (Type < (MAX_DEVICE_TYPE + 1)) && (Mode >= 0) && (Mode < MAX_DEVICE_MODES))
3960 if (InputInstance.
Calib[Type][Mode].
InUse == 0)
3969 InputInstance.
Calib[Type][Mode].
Min = Min;
3981 if ((Type > 0) && (Type < (MAX_DEVICE_TYPE + 1)) && (Mode >= 0) && (Mode < MAX_DEVICE_MODES))
3985 if (InputInstance.
Calib[Type][Mode].
InUse == 0)
3994 InputInstance.
Calib[Type][Mode].
Max = Max;
4005 if ((Type > 0) && (Type < (MAX_DEVICE_TYPE + 1)) && (Mode >= 0) && (Mode < MAX_DEVICE_MODES))
4027 case GET_CONNECTION :
4052 Tmp = (
DATA8)strlen((
char*)TmpName) + 1;
4060 if (pDestination !=
NULL)
4062 while ((Count < (Length - 1)) && (TmpName[Count]))
4064 pDestination[Count] = TmpName[Count];
4068 while (Count < (Length - 1))
4070 pDestination[Count] =
' ';
4076 if (pDestination !=
NULL)
4078 pDestination[Count] = 0;
4096 Tmp = (
DATA8)strlen((
char*)TmpName) + 1;
4104 if (pDestination !=
NULL)
4106 while ((Count < (Length - 1)) && (TmpName[Count]))
4108 pDestination[Count] = TmpName[Count];
4112 while (Count < (Length - 1))
4114 pDestination[Count] =
' ';
4120 if (pDestination !=
NULL)
4122 pDestination[Count] = 0;
4192 if ((Type >= 0) && (Type < (MAX_DEVICE_TYPE + 1)))
4208 Tmp = (
DATA8)strlen((
char*)TmpName) + 1;
4216 if (pDestination !=
NULL)
4218 while ((Count < (Length - 1)) && (TmpName[Count]))
4220 pDestination[Count] = TmpName[Count];
4224 while (Count < (Length - 1))
4226 pDestination[Count] =
' ';
4238 if (pDestination !=
NULL)
4240 pDestination[Count] = 0;
4254 #ifndef DISABLE_BUMBED
4308 #ifdef DEBUG_C_INPUT_DAISYCHAIN
4338 #ifdef DEBUG_TRACE_MODE_CHANGE
4339 printf(
"c_input opINPUT_DEVICE READY_XX: D=%-3d Change to type %d mode %d\r\n",Device,Type,Mode);
4345 #ifdef ENABLE_STATUS_TEST
4355 #ifdef DEBUG_TRACE_MODE_CHANGE
4356 printf(
"c_input opINPUT_DEVICE READY_XX: D=%-3d Trying to change to type %d mode %d\r\n",Device,Type,Mode);
4358 #ifdef ENABLE_STATUS_TEST
4383 #ifdef DEBUG_TRACE_MODE_CHANGE
4384 printf(
"c_input opINPUT_DEVICE READY_XX: D=%-3d Timeout when trying to change to type %d mode %d\r\n",Device,Type,Mode);
4394 while ((Value < Values) && (Value < MAX_DEVICE_DATASETS))
4441 #ifdef ENABLE_STATUS_TEST
4448 #ifdef ENABLE_STATUS_TEST
4468 while (Value < Values)
4511 if (pRdData !=
NULL)
4532 #ifndef DISABLE_DAISYCHAIN_COM_CALL
4556 DaisyBuf[2] = opINPUT_DEVICE;
4557 DaisyBuf[3] = CLR_ALL;
4604 #ifndef DISABLE_DAISYCHAIN_COM_CALL
4628 DaisyBuf[2] = opINPUT_DEVICE;
4629 DaisyBuf[3] = STOP_ALL;
4732 #ifdef DEBUG_C_INPUT_DAISYCHAIN
4733 printf(
"c_input opINPUT_READSI: D=%-3d B=%d\r\n",Device,InputInstance.
DeviceData[Device].
DevStatus);
4767 #ifdef DEBUG_C_INPUT_DAISYCHAIN
4768 printf(
"c_input opINPUT_TEST: D=%-3d B=%d\r\n",Device,InputInstance.
DeviceData[Device].
DevStatus);
4834 DATA8 Buffer[UART_DATA_LENGTH + 1];
4849 if ((Bytes > 0) && (Bytes <= UART_DATA_LENGTH))
4862 for (Tmp = 0;Tmp < Bytes;Tmp++)
4864 Buffer[Tmp + 1] = Data[Tmp];
4868 if (InputInstance.
UartFile >= MIN_HANDLE)
4870 write(InputInstance.
UartFile,Buffer,Bytes + 1);
4881 if ((Bytes > 0) && (Bytes <= IIC_DATA_LENGTH))
4894 for (Tmp = 0;Tmp < Bytes;Tmp++)
4896 Buffer[Tmp + 1] = Data[Tmp];
4900 if (InputInstance.
IicFile >= MIN_HANDLE)
4902 write(InputInstance.
IicFile,Buffer,Bytes + 1);
4971 while ((Value < Values) && (Value < MAX_DEVICE_MODES))
5011 while (Value < Values)
5092 Data32 = (
DATA32)NoOfPorts;
5093 if (Data32 > MIN_ARRAY_ELEMENTS)
5098 if (pValues !=
NULL)
5100 for (Index = 0;Index < NoOfPorts;Index++)
5103 Device = pDevices[Index];
5112 if ((Device >= 0) && (Device <
DEVICES))
5114 Type = pTypes[Index];
5115 Mode = pModes[Index];
5119 pValues[Index] =
cInputReadDeviceSi(Device,pDataSets[Index],SampleTime,&pInits[Index]);
DATAF PctMin
Percent minimum value (e.c. -100.0)
RESULT cDaisyDownStreamCmd(DATA8 *pData, DATA8 Length, DATA8 Layer)
DSPSTAT ExecuteByteCode(IP pByteCode, GP pGlobals, LP pLocals)
Execute byte code stream (C-call)
void SetDispatchStatus(DSPSTAT DspStat)
Set object (dispatch) status.
DATA8 Changed[INPUTS][MAX_DEVICE_MODES]
#define UART_DATA_READY
Data is ready.
UWORD IdValue
Device id value (e.c. 0 ~ UART)
signed char SBYTE
Basic Type used to symbolise 8 bit signed values.
#define EXT_CONFIG
rudolf configuration file
SBYTE Name[TYPE_NAME_LENGTH+1]
Device name.
DATAF Raw[MAX_DEVICE_DATASETS]
Raw value (only updated when "cInputReadDeviceRaw" function is called)
SWORD DATA16
VM Type for 2 byte signed value.
void LogErrorNumber(ERR Err)
DATA8 ConfigurationChanged[MAX_PROGRAMS]
SLONG DATA32
VM Type for 4 byte signed value.
UWORD OBJID
Object id type.
void SetObjectIp(IP Ip)
Set current instruction pointer.
Port empty or not available.
UWORD TypeIndex
Index to information in "TypeData" table.
RESULT cComSetDeviceType(DATA8 Layer, DATA8 Port, DATA8 Type, DATA8 Mode)
void * PrimParPointer(void)
Get next encoded parameter from byte code stream.
DATA8 DeviceType[DEVICES]
Type of all devices - for easy upload.
IP GetObjectIp(void)
Get current instruction pointer.
#define IIC_READ_TYPE_INFO
UWORD MaxDeviceTypes
Number of device type/mode entries in tabel.
void SetInstructions(ULONG Instructions)
Set instructions.
RESULT cMemoryMalloc(void **ppMemory, DATA32 Size)
OBJID CallingObjectId(void)
Get calling object id.
DATAF SiMin
SI unit minimum value (e.c. -100.0)
Port not empty but type has not been determined.
UWORD InvalidTime
mS from type change to valid data
IMGDATA * IP
Instruction pointer type.
RESULT cMemoryRealloc(void *pOldMemory, void **ppMemory, DATA32 Size)
SBYTE Symbol[SYMBOL_LENGTH+1]
SI unit symbol.
DATAF RawMax
Raw maximum value (e.c. 1023.0)
DATA8 Pins
Device pin setup.
DATAF SiMax
SI unit maximum value (e.c. 100.0)
unsigned int ULONG
Basic Type used to symbolise 32 bit unsigned values.
RESULT cComGetDeviceInfo(DATA8 Length, UBYTE *pInfo)
CALIB Calib[MAX_DEVICE_TYPE][MAX_DEVICE_MODES]
TYPES * TypeData
Type specific data.
UWORD IicDeviceTypes
Number of IIC device type/mode entries in tabel.
UBYTE Data[MAX_DEVICE_DATALENGTH]
#define MAX_DEVICE_INFOLENGTH
Number of bytes in the structure above (can not be changed)
#define UART_CLEAR_CHANGED
#define SYMBOL_LENGTH
Symbol leng th (not including zero)
#define UART_NACK_MODE_INFO
Port not empty and type is invalid.
RESULT cComSetDeviceInfo(DATA8 Length, UBYTE *pInfo)
#define UART_READ_MODE_INFO
#define IIC_DATA_READY
Data is ready.
DEVICE DeviceData[DEVICES]
Data for all devices.
Device is NXT IIC sensor.
#define IIC_WRITE_REQUEST
Write request.
#define UART_WRITE_REQUEST
Write request.
DATA8 WrData[IIC_DATA_LENGTH]
DATA8 RdData[IIC_DATA_LENGTH]
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
Port is connected to a terminal.
RESULT cComGetDeviceData(DATA8 Layer, DATA8 Port, DATA8 Length, DATA8 *pType, DATA8 *pMode, DATA8 *pData)
DATA8 SensorType[IIC_NAME_LENGTH+1]
FLOAT DATAF
VM Type for 4 byte floating point value.
unsigned short UWORD
Basic Type used to symbolise 16 bit unsigned values.
UBYTE IMGDATA
Image base type.
#define OUTPUTS
Number of output ports in the system.
DATAF RawMin
Raw minimum value (e.c. 0.0)
DATA8 TypeModes[MAX_DEVICE_TYPE+1]
No of modes for specific type.
UWORD InvalidTime
mS from type change to valid data
PRGID CurrentProgramId(void)
Get current program id.
void cOutputSetTypes(char *pTypes)
void * VmMemoryResize(HANDLER Handle, DATA32 Elements)
UWORD PRGID
Program id type.
DATA8 Manufacturer[IIC_NAME_LENGTH+1]
DATA8 Connection
Connection type (from DCM)
SBYTE DATA8
VM Type for 1 byte signed value.
DATA8 TmpMode[INPUT_PORTS]
DATA8 DeviceMode[DEVICES]
Mode of all devices.
#define UART_PORT_CHANGED
Input port changed.
#define INPUTS
Number of input ports in the system.
#define TYPE_PARAMETERS
Number of members in the structure above.
Break because of waiting for completion.
Dispatcher running (looping)
#define CHAIN_DEPT
Number of bricks in the USB daisy chain (master + slaves)
DATAF PctMax
Percent maximum value (e.c. 100.0)
UWORD TimeoutTimer
mS allowed to be busy timer