5 | | == iCAN == |
| 5 | == Get Weight == |
| 6 | |
| 7 | === Command prompt testing === |
| 8 | |
| 9 | Make sure no applications are running or the weight server. Otherwise, the application or weight server may grab the response before you are able to retrieve it from the command prompt. |
| 10 | |
| 11 | From the 825 command prompt type: |
| 12 | {{{ |
| 13 | echo "W" > /dev/wt1 |
| 14 | cat /dev/wt1 |
| 15 | WA01004456A486000000004456A4860000 |
| 16 | }}} |
| 17 | |
| 18 | The response "WA" indicates the response for the "W" weight request is acknowledged "A". The following characters are hexadecimal encoded values for the floating point gross, tare, net weights and weight status information. Because this data represents floating point math values it is difficult to interpret. You may change the weight on the scale and repeat the test to see that the values change. |
| 19 | |
| 20 | === Access the weight data from a program === |
| 21 | |
| 22 | The lib825 library provides features to facilitate access the weight information from an application program. |
| 23 | |
| 24 | {{{ |
| 25 | // Simple get weight sample |
| 26 | |
| 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> |
| 29 | |
| 30 | #include "mnbdcomm.h" |
| 31 | #include "lcd.h" |
| 32 | #include "util.h" |
| 33 | |
| 34 | int main() |
| 35 | { |
| 36 | int n; |
| 37 | char gross_wt_str[41]; |
| 38 | CSleep slp(0, 5); |
| 39 | |
| 40 | InitLCD(); |
| 41 | MnBdStartup(); |
| 42 | |
| 43 | while(1) |
| 44 | { |
| 45 | n = MnBdProcess(); |
| 46 | if(n == mnbdProcWtRcv) |
| 47 | { |
| 48 | FormatGrossWt(GetProcessWt(), gross_wt_str); |
| 49 | DisplayText(0, 0, gross_wt_str); |
| 50 | } |
| 51 | slp.Pause(); |
| 52 | } |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | }}} |
| 57 | |
| 58 | This displays the gross weight at the upper left corner of the display. The weight will update as changes are made to the scale. This program as an endless loop. If you started the program from the command line without using the "&" parameter you can press CTRL-C to end the program. Otherwise use PS to see the process list and KILL to terminate the appropriate process number. |
| 59 | |