OseComm

Availability All terminals
Description This routine uses the OseComm protocol to transmit and receive one or more complete files through the serial communications port that was last opened by ComOpen().
The OseComm protocol is not susceptible to timing issues, as opposed to the NetO protocol.

Features of protocol version 1.01:
- Fixed or Auto terminal ID
- Set time
- Get time
- Send file to terminal
- Receive file from terminal
- Get OS version
- Get application version
- List files on the terminal
- Delete files from the terminal.
Syntax long OseComm(long sessionID, int terminateKey, const char *appVersion, pOnOseCommInfo OnOseCommInfo);
Arguments
long sessionID
The communication identification number for the session.
The valid range is from 0 to 16.777.215 (0x000000 to 0xFFFFFF).
If the sessionID supplied is -1, the sessionID will be generated by the device.
int terminateKey
When this key is pressed the session is aborted.
CONNECTION_ABORT Abort when device is not connected to USB
ANY_KEYS_ABORT Abort when any key is pressed.
TRIGGER_KEY Abort when trigger key is pressed.
CLR_KEY Abort when function key is pressed.
const char *appVersion
A string holding the application version. When no version string, or an empty version string, is used, the terminal will send a command to get the unknown application version.
pOnOseCommInfo OnOseCommInfo
Callback function that gets the status, error, and progress information. NULL if no callback function is used.
Returns OK on success or an error code (negative value) specified as follows:
0 COMM_OK Communication OK.
-1 ERR_PR_NO_RESPONSE No response.
-2 ERR_PR_CRC CRC-16 error.
-3 ERR_PR_CMD_MISMATCH Wrong command received.
-4 ERR_HOST_REQ Host and terminal request did not match.
-5 ERR_PR_SESSION_ID Session ID mismatch.
-6 ERR_PR_SENDING_FRAME Error sending frame.
-7 ERR_PR_OPEN_FILE Cannot open or create the requested file.
-8 ERR_PR_READ_FROM_FILE Cannot read from file.
-9 ERR_PR_WRITE_TO_FILE Cannot write to file.
-10 ERR_PR_WRONG_BLOCK Requested the wrong block number.
-11 ERR_PR_FILE_SIZE Error in file sizes.
-12 ERR_PR_POLL_COMMAND Unexpected poll command.
-13 ERR_PR_FILE_UNAVAILABLE File cannot be found on the terminal.
-14 ERR_PR_LINE_BUSY Another terminal is already communicating.
-15 ERR_PR_TIME_DATE Error in the time or date when it is being set.
-20 ERR_PR_USER_ABORT User aborted the protocol.
Host software On our web site a Windows® application, called OseComm32, can be downloaded which can be used to send and/or receive files from a host device (PC) to an Opticon Handheld terminal using the OseComm protocol.
Example
#include <stdio.h>
#include "lib.h"

void OnOseComInfo(int status, int errorsuccess, int progress, const char *info)
{
    switch (status)
    {
    case STAT_GET_TIME_DATE:
        break;
    case STAT_SET_TIME_DATE:
        break;
    case STAT_GET_OS_VERSION:
        break;
    case STAT_GET_APPL_VERSION:
        break;
    case STAT_XMIT_FILE_TO_PC:
        // if successful then delete the file
        if (errorsuccess == SUCC_COMPLETE)
            remove(info);    // Delete the transfered file
        break;
    case STAT_RECV_FILE_FROM_PC:
        break;
    case STAT_LIST_FILES:
        break;
    }
}

void main(void)
{
    for (;;)
    {
        if (IsCharging())
        {
            printf("\nStart OseComm");
            if (OseComm( -1L, CONNECTION_ABORT, "OseComm Example", OnOseComInfo) == COMM_OK)
                printf("\nOseComm Success");
            else
                printf("\nOseComm aborted");
        }
        Idle();
    }
}