C Language Development Kit/Functions/NetO Receive
From OptiWiki
< C Language Development Kit | Functions(Redirected from C Language Development Kit/Functions/Neto receive)
| Description | This routine uses the NetO protocol to receive one or more complete files through the serial communications port that was last opened by comopen(). The NetO protocol is especially suited for a network environment. neto_receive2() can be given a time-out value. | ||||||||||||||||||
| Syntax | int neto_receive( char (*filename)[MAX_FNAME], char *term_id, int tkey, int ypos ); int neto_receive2( char (*filename)[MAX_FNAME], char *term_id, unsigned int timeout, int tkey, int ypos ); Note: On the OPH 100x and H 13, | ||||||||||||||||||
| Arguments | An array of strings, each string containing up to twelve characters plus the null character. Each string contains the name of the file that was received. Only when the reception was successful, does filename contain the valid names.char (*filename)[MAX_FNAME] The number of strings in the array is equal to the return value of neto_receive(), if no reception error occurred. Points to a string containing the name (or: ID) of the terminal. The string can have a maximum of 6 characters.
char *term_id unsigned int timeout timeout is the maximum time that may pass between calling the function and receiving a valid poll from the PC. Once a valid poll has been received, the protocol takes over and another time-out mechanism starts. The protocol specifies that when 3 seconds pass without receiving an answer from the PC a time-out error occurs.
Value for the termination key. When the user presses this key the file reception will terminate. Specify a non-existing value, e.g. -1, when you do not want to give the user the option to terminate file reception.
int tkey The y position (in character coordinates) of the progress bar. Use -1 to not display the progress bar. The progress information consists of three lines. On the first line is the file name. On the second line is the 0% ... 100% indicator. On the third line is the actual progress bar marked as a string of ******. ypos specifies the line on which the ****** will appear. The file name therefore will appear on line int yposypos - 2.
| ||||||||||||||||||
| Returns | The number of files (positive value) received if all files were received OK, or an error code (negative value) specified as follows: ERROR Error after three retries.
| ||||||||||||||||||
| Remarks | When these functions draw the progress bar, they change the cursor settings to AUTOWRAP, See the cursor() function for details.
Important:
| ||||||||||||||||||
| Example | // To use the following example the user must have access to a NetO protocol // upload and download utility on the host. The application first tries to receive // up to two files, and next tries to transmit the same file(s) back. // // The ENT key can be used to terminate the file reception/transmission. // // The terminal is assigned the terminal ID "123456". The terminal ID can be used to // distinguish the terminal from other terminals in a network. #include <stdio.h> #include "lib.h" void main( void ) { #ifdef OPH // OPH is defined when the code is build for the OPH1003! (So not the OPH1004) char ftest[10][16]; // Array for ten filenames; static not required for OPH1003 #else static char ftest[10][13]; // Array for ten filenames; static so space is not on stack #endif int test; systemsetting("K7"); // 19200bps (N, 8, 1) for(;;) { if( comopen( COM2 ) != OK) // COM2 is the cradle { printf("\fCan't open port"); resetkey(); while( !kbhit()) idle(); continue; } do { printf("\fReceiving.."); test = neto_receive( ftest, "123456", ENT_KEY, 3); printf("\ntest=%d", test); } while( test < 0); comclose( COM2 ); // Saves power printf("\fresult = %d", test); printf("\npress any key"); resetkey(); while( !kbhit()) idle(); if( comopen( COM2 ) != OK) { resetkey(); while( !kbhit()) idle(); continue; } printf("\fTransmitting...\n%d files", test); test = neto_transmit( ftest, test, "123456", ENT_KEY, 3); printf("\fresult = %d", test); printf("\npress any key"); comclose( COM2 ); resetkey(); while( !kbhit()) idle(); } } |
