//-------------------------------------------------------------------------- // Set the MicroLAN communucation speed. // // 'NewSpeed' - new speed defined as // MODE_NORMAL 0x00 // MODE_OVERDRIVE 0x01 // // Returns: current MicroLAN speed // int MLanSpeed(int NewSpeed) { uchar sendpacket[5]; short sendlen=0; int rt = FALSE; // check if change from current mode if (((NewSpeed == MODE_OVERDRIVE) && (USpeed != SPEEDSEL_OD)) || ((NewSpeed == MODE_NORMAL) && (USpeed != SPEEDSEL_FLEX))) { if (NewSpeed == MODE_OVERDRIVE) { // if overdrive then switch to 115200 baud if (DS2480ChangeBaud(PARMSET_57600) == PARMSET_57600) { USpeed = SPEEDSEL_OD; rt = TRUE; } } else if (NewSpeed == MODE_NORMAL) { // else normal so set to 9600 baud if (DS2480ChangeBaud(PARMSET_9600) == PARMSET_9600) { USpeed = SPEEDSEL_FLEX; rt = TRUE; } } // if baud rate is set correctly then change DS2480 speed if (rt) { // check if correct mode if (UMode != MODSEL_COMMAND) { UMode = MODSEL_COMMAND; sendpacket[sendlen++] = MODE_COMMAND; } // proceed to set the DS2480 communication speed sendpacket[sendlen++] = CMD_COMM | FUNCTSEL_SEARCHOFF | USpeed; // send the packet if (!WriteCOM(sendlen,sendpacket)) { rt = FALSE; // lost communication with DS2480 then reset DS2480Detect(); } } } // return the current speed return (USpeed == SPEEDSEL_OD) ? MODE_OVERDRIVE : MODE_NORMAL; }
//-------------------------------------------------------------------------- // Set the 1-Wire Net communucation speed. // // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to // OpenCOM to indicate the port number. // 'new_speed' - new speed defined as // MODE_NORMAL 0x00 // MODE_OVERDRIVE 0x01 // // Returns: current 1-Wire Net speed // SMALLINT owSpeed(int portnum, SMALLINT new_speed) { uchar sendpacket[5]; uchar sendlen=0; uchar rt = FALSE; // check if change from current mode if (((new_speed == MODE_OVERDRIVE) && (USpeed[portnum] != SPEEDSEL_OD)) || ((new_speed == MODE_NORMAL) && (USpeed[portnum] != SPEEDSEL_FLEX))) { if (new_speed == MODE_OVERDRIVE) { // if overdrive then switch to 115200 baud if (DS2480ChangeBaud(portnum,PARMSET_115200) == PARMSET_115200) { USpeed[portnum] = SPEEDSEL_OD; rt = TRUE; } } else if (new_speed == MODE_NORMAL) { // else normal so set to 9600 baud if (DS2480ChangeBaud(portnum,PARMSET_9600) == PARMSET_9600) { USpeed[portnum] = SPEEDSEL_FLEX; rt = TRUE; } } // if baud rate is set correctly then change DS2480 speed if (rt) { // check if correct mode if (UMode[portnum] != MODSEL_COMMAND) { UMode[portnum] = MODSEL_COMMAND; sendpacket[sendlen++] = MODE_COMMAND; } // proceed to set the DS2480 communication speed sendpacket[sendlen++] = CMD_COMM | FUNCTSEL_SEARCHOFF | USpeed[portnum]; // send the packet if (!WriteCOM(portnum,sendlen,sendpacket)) { OWERROR(OWERROR_WRITECOM_FAILED); rt = FALSE; // lost communication with DS2480 then reset DS2480Detect(portnum); } } } // return the current speed return (USpeed[portnum] == SPEEDSEL_OD) ? MODE_OVERDRIVE : MODE_NORMAL; }