// Create must be turned on and connected. This routine establishes serial link // Note that this routine should be called once, and must have been called before // any of the other create functions will work. Puts Create in "safe" mode (see documentation). // Once this function is called, you cannot talk to the XBC over the USB connection // until the create_disconnect function has been called or the GBA on the XBC has been power cycled. // If Create is connected, power light goes yellow and play led turns on int create_connect() { gc_mode=2; create_start(); create_safe(); create_advance_led(1); // turn on advance LED return(0);//successful connection }
/* * Class: cbccore_low_Create * Method: create_start * Signature: ()V */ JNIEXPORT void JNICALL Java_cbccore_low_Create_create_1start(JNIEnv *env, jobject obj) { #ifdef CBC create_start(); #else printf("Java_cbccore_low_Create_create_1start stub\n"); #endif }
// Create must be turned on and connected. This routine establishes serial link // Note that this routine should be called once, and must have been called before // any of the other create functions will work. // If Create is connected, power light goes yellow and play led turns on int create_connect() { gc_mode=0; serial_init(); create_start(); create_safe(); //allows create to be commanded and turns LED orange create_mode();//gets mode and sets global gc_mode if (gc_mode!=2) { // if not safe mode, connection not established printf("Create connect failed, mode is %d\n", gc_mode); g_create_connected = 0; msleep(100); beep(); msleep(100); beep(); return(-1);//connection failed } create_advance_led(1); // turn on advance LED g_create_connected = 1; atexit(create_disconnect); return(0);//successful connection }
int main(int argc, char ** argv) { int i; printf("Connecting...\n"); create_connect(); create_start(); printf("Spinning CW...n"); create_spin_CW(40); // spin a while CW for (i = 0; i < 10; ++i) { printf("Distance: %d Angle: %d\n", get_create_distance(), get_create_total_angle()); msleep(1000); } printf("Spinning CCW...n"); create_spin_CCW(40); // spin a while CCW for (i = 0; i < 10; ++i) { printf("Distance: %d Angle: %d\n", get_create_distance(), get_create_total_angle()); msleep(1000); } printf("Stopping...\n"); create_stop(); printf("Disconnecting...\n"); create_disconnect(); printf("Done.\n"); return 0; }
bool xml_snk_element_break(xmlNodePtr element, xml_snk_element_create_fn *create_start, xml_snk_element_create_fn *create_end) { xmlNodePtr sibling; xmlNodePtr child; xmlNodePtr next_child; xmlAttrPtr prop; xmlAttrPtr last_prop; assert(element != NULL); assert(element->parent != NULL); /* If starting element is NOT requested */ if (create_start == NULL) sibling = element; else { /* Create starting element */ sibling = create_start(element->doc, element->ns); if (sibling == NULL) return false; /* Add it right after the original one */ sibling = xmlAddNextSibling(element, sibling); if (sibling == NULL) return false; /* Copy original element's property list, if not empty */ if (element->properties != NULL) { prop = xmlCopyPropList(sibling, element->properties); if (prop == NULL) return false; /* * Attach copied property list to the created element property * list. */ if (sibling->properties == NULL) sibling->properties = prop; else { /* Find the last property */ for (last_prop = sibling->properties; last_prop->next == NULL; last_prop = last_prop->next); last_prop->next = prop; prop->prev = last_prop; } } } /* For each child of the original element */ for (child = element->children; child != NULL; child = next_child) { /* Remember next child before this one is unlinked */ next_child = child->next; /* Move the child after the new element */ sibling = xmlAddNextSibling(sibling, child); if (sibling == NULL) return false; } /* If ending element is requested */ if (create_end != NULL) { /* Create ending element */ sibling = create_end(element->doc, element->ns); if (sibling == NULL) return false; /* Add it right after the contents */ sibling = xmlAddNextSibling(element, sibling); if (sibling == NULL) return false; } /* Unlink original element */ xmlUnlinkNode(element); /* Free original element */ xmlFreeNode(element); return true; }
/* * Envoi d'un message Start a tous les joueurs encore connectes (broadcast) * @param the_players Liste des joueurs * @param msg Message a envoyer */ void send_start(Players the_players, const char* msg) { Frame start_frame = create_start(msg); send_broadcast(the_players, start_frame); }