Changes between Version 4 and Version 5 of Docs/Prog/Manual/DeviceSupport/SerialPorts


Ignore:
Timestamp:
05/09/19 10:56:48 (5 years ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/Prog/Manual/DeviceSupport/SerialPorts

    v4 v5  
    252252This sample displays updating weight on the LCD display and will exit when the Shift-ESC key on the keypad is pressed. If CTRL-F is received on the COM2 port this application will send "ACK received<CR><LF>" out the serial port in response. If CTRL-U is received on the COM2 port this application will send "NACK received<CR><LF>" out the serial port in response. If CTRL-B is received the application will start buffering subsequent received characters. When CTRL-C is received the application will respond back with the buffered characters and stop buffering.
    253253
     254Since COM3 and COM4 are handled by the mainboard processor they allow repeating outputs to be specified with variables for weight, units, etc... This is used by the CScoreboard class in applications such as ID storage. This can be useful because the application can just specify the output and does not have to continue sending constantly.
     255
     256
     257{{{
     258
     259        bool SetMnBdRepeatFormat(void)
     260        {
     261                g_serial_fmt.fmt = 1;
     262
     263                switch(_format)
     264                {
     265                case FMT_SB500:
     266                        if(_sbOverCap)
     267                        {
     268                                strcpy((char*)g_serial_fmt.data, "%%%0 O CAP   r\r");
     269                        }
     270                        else
     271                        {
     272                                if(_scale == 0)
     273                                {
     274                                        strcpy((char*)g_serial_fmt.data, "%%%0%G6%%U%G \r");
     275                                        g_serial_fmt.data[12] = _sbLightCode;
     276                                }
     277                                else
     278                                {
     279                                        sprintf((char*)g_serial_fmt.data, "%%%%%%0%%G(%d)6%%%%U%%G%c\r", _scale, _sbLightCode);
     280                                }
     281                        }
     282                        break;
     283                case FMT_COMPIF:
     284                        strcpy((char*)g_serial_fmt.data, "%G% %U% G %M%  \r");
     285                        break;
     286                case FMT_SB200:
     287                        strcpy((char*)g_serial_fmt.data, "%G% %U% G %M%  \r");
     288                        break;
     289                case FMT_GENERIC:
     290                        strcpy((char*)g_serial_fmt.data, "%G% %U% G %M%  \r");
     291                        break;
     292                default:
     293                        strcpy((char*)g_serial_fmt.data, "%G% %U% G %M%  \r");
     294                }
     295
     296                g_serial_fmt.len = strlen((char*)g_serial_fmt.data);
     297
     298                if(MnBdRequest(MNBD_DEV, MNBD_REQ_SET_SERIAL_FMT, WAIT_ACK) != OK)
     299                {
     300                        _errStr = "Error setting format\r\n";
     301                        return false;
     302                }
     303                else
     304                {
     305                        return true;
     306                }
     307        }
     308
     309
     310}}}
     311
     312Variables
     313
     314%<item code><len>%
     315
     316item code:
     317
     318G - Gross weight
     319T - Tare weight
     320N - Net weight
     321U - upper case weight units
     322u - lower case weight units
     323C - weight status
     324S - SMA weight status
     325M - motion status
     326
     327Use two percent characters %% to output a percent character
     328 
     329
    254330[[Top]]