void javax_wukong_wkpf_WKPF_void_createWuObject_short_byte_javax_wukong_wkpf_VirtualWuObject()
{
	dj_object *java_instance_reference = REF_TO_VOIDP(dj_exec_stackPopRef());
	uint8_t port_number = (uint8_t)dj_exec_stackPopShort();
	uint16_t wuclass_id = (uint16_t)dj_exec_stackPopShort();
	DEBUG_LOG(DBG_WKPF, "WKPF: Creating wuobject for virtual wuclass with id %x at port %x (ref: %p)\n", wuclass_id, port_number, java_instance_reference);
	wkpf_error_code = wkpf_create_wuobject(wuclass_id, port_number, java_instance_reference, false);
}
void javax_wukong_wkpf_WKPF_void_setPropertyBoolean_javax_wukong_wkpf_VirtualWuObject_byte_boolean() {
	bool value = (int16_t)dj_exec_stackPopShort();
	uint8_t property_number = (uint8_t)dj_exec_stackPopShort();
	dj_object *java_instance_reference = REF_TO_VOIDP(dj_exec_stackPopRef());
	wuobject_t *wuobject;
	wkpf_error_code = wkpf_get_wuobject_by_java_instance_reference(java_instance_reference, &wuobject);
	if (wkpf_error_code == WKPF_OK) {
		wkpf_error_code = wkpf_internal_write_property_boolean(wuobject, property_number, value);
	}
}
void javax_wukong_wkpf_WKPF_void_registerWuClass_short_byte__()
{
	dj_int_array *byteArrayProperties = REF_TO_VOIDP(dj_exec_stackPopRef());
	// check null
	if (byteArrayProperties==nullref){
		dj_exec_createAndThrow(BASE_CDEF_java_lang_NullPointerException);
	}
	uint16_t wuclass_id = (uint16_t)dj_exec_stackPopShort();
	DEBUG_LOG(DBG_WKPF, "WKPF: Registering virtual wuclass with id %x\n", wuclass_id);
	wkpf_error_code = wkpf_register_virtual_wuclass(wuclass_id, NULL, byteArrayProperties->array.length, (uint8_t *)byteArrayProperties->data.bytes);
}
void javax_wukong_wkpf_WKPF_short_getPropertyShort_javax_wukong_wkpf_VirtualWuObject_byte()
{
	uint8_t property_number = (uint8_t)dj_exec_stackPopShort();
	dj_object *java_instance_reference = REF_TO_VOIDP(dj_exec_stackPopRef());
	wuobject_t *wuobject;
	wkpf_error_code = wkpf_get_wuobject_by_java_instance_reference(java_instance_reference, &wuobject);
	if (wkpf_error_code == WKPF_OK) {
		int16_t value;
		wkpf_error_code = wkpf_internal_read_property_int16(wuobject, property_number, &value);
		dj_exec_stackPushShort(value);
	}
}
// void javax.darjeeling.Darjeeling.printBytesAsString(byte[])
void javax_darjeeling_Darjeeling_void_printBytesAsString_byte__()
{
    dj_int_array* byteStr = REF_TO_VOIDP(dj_exec_stackPopRef());
    // check null
    if (byteStr==nullref) {
        dj_exec_createAndThrow(BASE_CDEF_java_lang_NullPointerException);
    }

    //nesc_printf(byteStr->data.bytes);
    if (nesc_printf(byteStr->data.bytes)==0)
        blockThreadForPrintf();
}
// void javax.darjeeling.Darjeeling.printBytesAsString(byte[])
void javax_darjeeling_Darjeeling_void_printBytesAsString_byte__()
{
	dj_int_array* byteStr = REF_TO_VOIDP(dj_exec_stackPopRef());
	char* str = byteStr->data.bytes;

#ifdef IS_COOJA
	DARJEELING_PRINTF("\n(Node %d) ---> %s", node_id, str);
	ASSEMBLY_DEBUG("(Node %d) ---> %s", node_id, str);
#else
	printf("%s", str);
#endif
}
// void javax.ostfriesentee.Ostfriesentee._print(byte[])
void javax_ostfriesentee_Ostfriesentee_void__print_byte__()
{
	// Get byte array
	dj_int_array * byteArray = (dj_int_array*)REF_TO_VOIDP(dj_exec_stackPopRef());

	if (byteArray == NULL)
	{
		dj_exec_createAndThrow(BASE_CDEF_java_lang_NullPointerException);
		return;
	}

	write(1, byteArray->data.bytes, byteArray->array.length);
}
// void javax.darjeeling.Darjeeling.print(byte[])
void javax_darjeeling_Darjeeling_void_print_byte__() {
    int i;
    dj_int_array * byteArray = REF_TO_VOIDP(dj_exec_stackPopRef());
    // check null
    if (byteArray==nullref) {
        dj_exec_createAndThrow(BASE_CDEF_java_lang_NullPointerException);
    }
    char temp[byteArray->array.length];
    for (i = 0; i < byteArray->array.length; i ++) {
        temp[i] = byteArray->data.bytes[i];
    }
    if (nesc_printf(temp)==0)
        blockThreadForPrintf();
}
javax_virtualsense_network_Packet_byte___toByteArray(){
	 uint8_t i = 0;
	 dj_object *obj = REF_TO_VOIDP(dj_exec_stackPopRef());
	 heap_chunk * chk = getChunk(obj);
	 dj_int_array * ret;
	 uint16_t length = chk->size;
	 PRINTF("obj id is %d and array size is %d \n", chk->id, chk->size);
	 ret = dj_int_array_create(T_BYTE, length);
	 // data.bytes conatains | chunk struct | chk->size -sizeof(heap_chunk) bytes |
	 memcpy(ret->data.bytes, (char*)chk, length);
	 for(i = 0; i < ret->array.length; i++)
		 PRINTF("%x-", ret->data.bytes[i]);
	 PRINTF("\n");
	 dj_exec_stackPushRef(VOIDP_TO_REF(ret));

}
// byte[] javax.darjeeling.io.ProgramFlash.read(int)
void javax_darjeeling_io_ProgramFlash_byte____read_int()
{
	// Pop arguments.
	/*uint32_t index = */dj_exec_stackPopInt();
	/*ref_t obj = */dj_exec_stackPopRef();

	// Allocate byte array.
	dj_int_array * arr = dj_int_array_create(T_BYTE, PROGFLASH_BLOCKSIZE);

	// Read data from 'program flash'.

	// TODO implement ...

	// Return data.
	dj_exec_stackPushRef(VOIDP_TO_REF(arr));
}
Пример #11
0
// void javax.radio.Radio._broadcast(byte[])
void javax_radio_Radio_void__broadcast_byte__()
{
	dj_thread * currentThread = dj_exec_getCurrentThread();

	// get byte array to send
	dj_int_array * arr = REF_TO_VOIDP(dj_exec_stackPopRef());
	if (tossim_send((char*)arr->data.bytes, 0xffff, arr->array.length)==0)
	{
		// block the current thread for IO
		dj_vm* vm = dj_exec_getVM();
		DEBUG_LOG(DBG_DARJEELING, DARJEELING, "broadcast stops\t\tthread[%p]\n", currentThread);
		currentThread->status = THREADSTATUS_BLOCKED_FOR_IO;
		_global_radio_sendThreadId = currentThread->id;
		dj_exec_breakExecution();
	}

}
Пример #12
0
// boolean javax.radio.Radio._send(short, byte[])
void javax_radio_Radio_boolean__send_short_byte__()
{
	dj_thread * currentThread = dj_exec_getCurrentThread();

	// get byte array to send
	dj_int_array * arr = REF_TO_VOIDP(dj_exec_stackPopRef());
	int16_t id = dj_exec_stackPopShort();

	if (tossim_send((char*)arr->data.bytes, id, arr->array.length)==0)
	{
		// block the current thread for IO
		DEBUG_LOG(DBG_DARJEELING, DARJEELING, "send stops thread[%p]\n", currentThread);
		currentThread->status = THREADSTATUS_BLOCKED_FOR_IO;
		_global_radio_sendThreadId = currentThread->id;
		dj_exec_breakExecution();
	}

	dj_exec_stackPushShort(tossim_wasAcked());

}
// byte[] javax.darjeeling.io.ProgramFlash.read(int)
void javax_darjeeling_io_ProgramFlash_byte____read_int()
{
	// Pop arguments.
	// TODO: use when this gets implemented, but for now discard the index to avoid compiler warning
	// uint32_t index = dj_exec_stackPopInt();
	dj_exec_stackPopInt();

	// ignore the 'this' argument
	dj_exec_stackPopRef();

	// Allocate byte array.
	dj_int_array * arr = dj_int_array_create(T_BYTE, PROGFLASH_BLOCKSIZE);

	// Read data from 'program flash'.

	// TODO implement ...

	// Return data.
	dj_exec_stackPushRef(VOIDP_TO_REF(arr));
}
// int javax.darjeeling.io.ProgramFlash.getBlockCount()
void javax_darjeeling_io_ProgramFlash_int_getBlockCount()
{
	dj_exec_stackPushInt((uint32_t)PROGFLASH_BLOCKCOUNT);
	/*ref_t obj = */dj_exec_stackPopRef();
}
void javax_darjeeling_Darjeeling_void__print_java_lang_String()
{
	// Pop string object from the stack.
	BASE_STRUCT_java_lang_String * stringObject = (BASE_STRUCT_java_lang_String*)REF_TO_VOIDP(dj_exec_stackPopRef());

	if (stringObject == NULL)
	{
		dj_exec_createAndThrow(BASE_CDEF_java_lang_NullPointerException);
		return;
	}

	// Get byte array
	dj_int_array * byteArray = (dj_int_array*)REF_TO_VOIDP(stringObject->value);

	if (byteArray == NULL)
	{
		dj_exec_createAndThrow(BASE_CDEF_java_lang_NullPointerException);
		return;
	}

	for (int i=0; i<byteArray->array.length; i++)
		printf("%c", byteArray->data.bytes[i]);
}
void javax_wukong_wkpf_WKPF_void_loadLinkDefinitions_byte__() {
	dj_int_array *links = REF_TO_VOIDP(dj_exec_stackPopRef());
	wkpf_error_code = wkpf_load_links(links);    
}
void javax_wukong_wkpf_WKPF_void_loadComponentToWuObjectAddrMap_java_lang_Object__() {
	dj_ref_array *map = REF_TO_VOIDP(dj_exec_stackPopRef());
	wkpf_error_code = wkpf_load_component_to_wuobject_map(map);
}
// void javax.darjeeling.Darjeeling.printBytesAsString(byte[])
void javax_darjeeling_Darjeeling_void_printBytesAsString_byte__()
{
	dj_int_array* byteStr = REF_TO_VOIDP(dj_exec_stackPopRef());
	printf("%s", byteStr->data.bytes);
}
// void javax.ostfriesentee.Ostfriesentee._print(java.lang.String)
void javax_ostfriesentee_Ostfriesentee_void__print_java_lang_String()
{
	// Pop string object from the stack.
	BASE_STRUCT_java_lang_String * stringObject = (BASE_STRUCT_java_lang_String*)REF_TO_VOIDP(dj_exec_stackPopRef());

	if (stringObject == NULL)
	{
		dj_exec_createAndThrow(BASE_CDEF_java_lang_NullPointerException);
		return;
	}

	// Get byte array
	dj_int_array * byteArray = (dj_int_array*)REF_TO_VOIDP(stringObject->value);

	if (byteArray == NULL)
	{
		dj_exec_createAndThrow(BASE_CDEF_java_lang_NullPointerException);
		return;
	}

	write(1, byteArray->data.bytes, stringObject->count);
}
// void javax.darjeeling.Darjeeling.printBytesAsString(byte[])
void javax_darjeeling_Darjeeling_void_printBytesAsString_byte__()
{
	dj_int_array* byteStr = REF_TO_VOIDP(dj_exec_stackPopRef());
	char* str = byteStr->data.bytes;
	tossim_printf(str);
}
// short javax.darjeeling.io.ProgramFlash.getBlockSize()
void javax_darjeeling_io_ProgramFlash_short_getBlockSize()
{
	dj_exec_stackPushShort((uint16_t)PROGFLASH_BLOCKSIZE);
	/*ref_t obj = */dj_exec_stackPopRef();
}