int sendHdlPacage(hdlDataPacage hdlPacage){ hdlDataPacage localHdlDataPacage = hdlPacage; char txBuffer[100]; int i; unsigned int crc; txBuffer[0] = RS_HEADER[0]; txBuffer[1] = RS_HEADER[1]; txBuffer[2] = (char)(MIN_PACKAGE_SIZE + localHdlDataPacage.additionContent.size); txBuffer[3] = localHdlDataPacage.orgSubnet; txBuffer[4] = localHdlDataPacage.orgDeviceId; txBuffer[5] = getHighByte(localHdlDataPacage.devType); txBuffer[6] = getLowByte(localHdlDataPacage.devType); txBuffer[7] = getHighByte(localHdlDataPacage.operCode); txBuffer[8] = getLowByte(localHdlDataPacage.operCode); txBuffer[9] = localHdlDataPacage.targSubnet; txBuffer[10]= localHdlDataPacage.targId; if (localHdlDataPacage.additionContent.size > 0){ for (i = 11; (localHdlDataPacage.additionContent.size + 10); i++){ txBuffer[i] = localHdlDataPacage.additionContent.content[i-10]; } } i = 10 + localHdlDataPacage.additionContent.size; crc = calculateCRC((unsigned int)i, txBuffer); i+=1; txBuffer[i] = getHighByte(crc); i+=1; txBuffer[i] = getLowByte(crc); open_closeUART(1); // write(uart0_filestream, &tx_buffer, sizeof(txBuffer); open_closeUART(0); }
void ARRAY3600OBJ::setParameters(byte address, int maxI, int maxU, int maxP, int u) { byte command[] = { 0xAA, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; command[1] = address; command[3] = getLowByte(maxI); command[4] = getHighByte(maxI); command[5] = getLowByte(maxU); command[6] = getHighByte(maxU); command[9] = getLowByte(maxP); command[10] = getHighByte(maxP); command[11] = getLowByte(u); command[12] = getHighByte(u); command[25] = getCheckByte(command); WriteComPort(comdev, command, 26); }
void ConstantLong::customSerialize(JBuffer* buf, UINT& pos) { /* u1 tag; u4 high_bytes; u4 low_bytes; */ ToolKit::memSetU4(buf->getBuffer(), getHighByte(), buf->getSize(), pos); ToolKit::memSetU4(buf->getBuffer(), getLowByte(), buf->getSize(), pos); }
std::size_t DefaultBitImageCommands::setPageModePrintArea(int x, int y, int width, int height) { uint8_t xL = getLowByte(x); uint8_t xH = getHighByte(x); uint8_t yL = getLowByte(y); uint8_t yH = getHighByte(y); uint8_t dXL = getLowByte(width); uint8_t dXH = getHighByte(width); uint8_t dYL = getLowByte(height); uint8_t dYH = getHighByte(height); const uint8_t command[10] = {BaseCodes::ESC, 'W', xL, xH, yL, yH, dXL, dXH, dYL, dYH }; return writeBytes(command,10); }
int ToolKit::memSetU2(BYTE* array, u2 value, UINT size, UINT& pos) { int result = -1; if((pos + sizeof(u2)) <= size) { u1 high, low; high = getHighByte(value); low = getLowByte(value); array[pos] = high; pos++; array[pos] = low; pos++; result = pos; } return result; }
std::size_t DefaultBitImageCommands::selectBitImageMode(const ofPixels_<unsigned char>& binaryPixels, BaseCodes::PrintResolution printResolution) { // width = nL + (nH * 256) // nH is the HIGH part of the WIDTH VALUE. // nL is the LOW part of the WIDTH VALUE. // nH will always be 0 for values less that 256 (1 byte) uint8_t nH = getHighByte(binaryPixels.getWidth()); uint8_t nL = getLowByte(binaryPixels.getWidth()); std::vector<uint8_t> buffer; buffer.push_back(BaseCodes::ESC); buffer.push_back('*'); buffer.push_back(printResolution); buffer.push_back(nL); buffer.push_back(nH); uint8_t currentByte = 0; int bitIndex = 0; for(int x = 0; x < binaryPixels.getWidth(); ++x) { currentByte = 0; bitIndex = 0; for(int y = 0; y < binaryPixels.getHeight(); ++y) { bool binaryValue = binaryPixels[binaryPixels.getPixelIndex(x,y)] < ofColor_<unsigned char>::limit() / 2; currentByte |= binaryValue << (7 - bitIndex); bitIndex++; if(8 == bitIndex) { buffer.push_back(currentByte); currentByte = 0; bitIndex = 0; } } } return writeBytes(buffer); }