示例#1
0
STATIC void putIndex( type_rec *tr, uint_16 word ) {

    uint_8  *p;

    p = getTrData( tr, 3 );
    p[0] = MS_BCL_INDEX;
    WriteU16( p + 1, word );
}
示例#2
0
void Info16(
    dw_client                   cli,
    uint_16                     value )
{
    char                        buf[ sizeof( uint_16 ) ];

    WriteU16( buf, value );
    CLIWrite( DW_DEBUG_INFO, &buf, sizeof( buf ) );
}
示例#3
0
文件: DataIO.cpp 项目: Jeffxz/nodeas
	void DataOutput::WriteUTF(String *str)
	{
		StUTF8String utf8(str);
		uint32_t length = utf8.length();
		if (length > 65535) {
			ThrowRangeError();
		}
		WriteU16((unsigned short)length);
		Write(utf8.c_str(), length*sizeof(char));
	}
示例#4
0
STATIC void putUnsigned( type_rec *tr, uint_32 num ) {

    uint_8  *p;

    if( num < 0x80 ) {
        p = getTrData( tr, 1 );
        p[0] =   num & 0x000000ff;
    } else if( num < 0x10000 ) {
        p = getTrData( tr, 3 );
        p[0] = MS_BCL_UINT_16;
        WriteU16( p+1, num );
    } else {
        p = getTrData( tr, 5 );
        p[0] = MS_BCL_UINT_32;
        WriteU32( p+1, num );
    }
}
示例#5
0
static void bus_simple_send(u32 adapterId, u32 desId,u8 functionId  ,u8 sessionId, u32 data_len, u8 *data)
{
	//BUS_LOG("simple func=%d ses=%d len=%d \r\n", functionId,sessionId,data_len);
	int frame_count = (data_len + 5) / 6;

	bus_os_pend_sem(&tx_mutex_sem, 0);
	for (int i = 0; i < frame_count + 1; i++)
	{
		bus_frame frame;
		frame.adapterId = adapterId;
		frame.desId = desId;
		frame.srcId = bus_local_id;
		frame.functionId = functionId;
		frame.sessionId = sessionId;
		WriteU16(frame.data, i);

		if (i == 0)
		{
			frame.data_len = 6;
			WriteU32(frame.data + 2, data_len);
		}
		else
		{
			int frame_data_len = (i == frame_count) ? ((data_len % 6) == 0 ? 6 : (data_len % 6)) : 6;
			frame.data_len = frame_data_len + 2;
			//把数据复制过去
			memmove(frame.data + 2, data + (i - 1) * 6, frame_data_len);
		}

		//查找网卡 发送数据
		for (bus_adapter *adp = adapterList; adp != NULL; adp = adp->next)
		{
			if (adp->adatperId == adapterId)
			{
				adp->adapter_send(adp,frame.desId, frame.functionId, frame.sessionId, 0, frame.data_len, frame.data);
			}
		}
	}
	bus_os_post_sem(&tx_mutex_sem);
}