/* Reply has been mostly initialised by do_command */ void send_reply() { int i; if ((vtcmd.cmd)==VTC_QUICK) { /* Only send buffer on a quick read */ writeP(portfd, &vtreply.cmd, 1); if (vtreply.cmd!=VTC_QUICK) return; /* Must have been an error */ for (i=0; i< BLKSIZE; i++) writeP(portfd, &inbuf[i], 1); return; } sum0 = 0; sum1 = 0; /* Transmit the reply */ write0(portfd, &vtreply.hdr1, 1); write1(portfd, &vtreply.hdr2, 1); write0(portfd, &vtreply.cmd, 1); write1(portfd, &vtreply.record, 1); if(block<0xff00) { unsigned char tmp; tmp = block; write0(portfd, &tmp, 1); tmp = block>>8; write1(portfd, &tmp, 1); }
JNIEXPORT jint JNICALL Java_io_netty_channel_epoll_Native_write(JNIEnv * env, jclass clazz, jint fd, jobject jbuffer, jint pos, jint limit) { void *buffer = (*env)->GetDirectBufferAddress(env, jbuffer); if (buffer == NULL) { throwRuntimeException(env, "Unable to access address of buffer"); return -1; } return write0(env, clazz, fd, buffer, pos, limit); }
/******************************************************************** 函数名称:write1byte 功 能:向I2C总线发送一个字节的数据 参 数:WriteData--发送的数据 返回值 :无 ********************************************************************/ void write1byte(uchar WriteData) { uchar i; for(i = 8;i > 0;i--) { if(WriteData & 0x80) write1(); else write0(); WriteData <<= 1; } SDA_H; _NOP(); }
JNIEXPORT jint JNICALL Java_io_netty_channel_epoll_Native_write(JNIEnv * env, jclass clazz, jint fd, jobject jbuffer, jint pos, jint limit) { void *buffer = (*env)->GetDirectBufferAddress(env, jbuffer); if (buffer == NULL) { throwRuntimeException(env, "Unable to access address of buffer"); return -1; } jint res = write0(env, clazz, fd, buffer, pos, limit); if (res > 0) { // Increment the pos of the ByteBuffer as it may be only partial written to prevent data-corruption later once we // try to write the remaining data. // See https://github.com/netty/netty/issues/2371 incrementPosition(env, jbuffer, res); } return res; }
// pat added: write an Optional Field controlled by an initial 0/1 field. void MsgCommonWrite::writeOptField01(uint64_t value, unsigned len, int present, const char*) { if (present) { write1(); writeField(value,len); } else { write0(); } }
JNIEXPORT jint JNICALL Java_io_netty_channel_epoll_Native_writeAddress(JNIEnv * env, jclass clazz, jint fd, jlong address, jint pos, jint limit) { return write0(env, clazz, fd, (void *) address, pos, limit); }