LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_com.c File Reference
#include "c_com.h"
#include "lms2012.h"
#include "c_bt.h"
#include "c_wifi.h"
#include "c_daisy.h"
#include "c_md5.h"
#include "c_i2c.h"
#include "c_output.h"
#include "c_memory.h"

Go to the source code of this file.

Macros

#define USB_CABLE_DETECT_RATE   15000
 
#define SIZEOFFILESIZE   8
 

Enumerations

enum  { FS_IDLE }
 

Functions

void setComInstance (COM_GLOBALS *_Instance)
 
COM_GLOBALSgetComInstance ()
 
UWORD cComReadBuffer (UBYTE *pBuffer, UWORD Size)
 
UWORD cComWriteBuffer (UBYTE *pBuffer, UWORD Size)
 
UBYTE cComFindMailbox (UBYTE *pName, UBYTE *pNo)
 
void cComSetMusbHdrcMode (void)
 
RESULT cComInit (void)
 
RESULT cComOpen (void)
 
RESULT cComClose (void)
 
RESULT cComExit (void)
 
RESULT cComSetDeviceInfo (DATA8 Length, UBYTE *pInfo)
 
RESULT cComGetDeviceInfo (DATA8 Length, UBYTE *pInfo)
 
RESULT cComSetDeviceType (DATA8 Layer, DATA8 Port, DATA8 Type, DATA8 Mode)
 
RESULT cComGetDeviceData (DATA8 Layer, DATA8 Port, DATA8 Length, DATA8 *pType, DATA8 *pMode, DATA8 *pData)
 
UBYTE cComCheckUsbCable (void)
 
UBYTE cComDirectCommand (UBYTE *pBuffer, UBYTE *pReply)
 
void cComCloseFileHandle (SLONG *pHandle)
 
UBYTE cComFreeHandle (DATA8 Handle)
 
DATA8 cComGetHandle (char *pName)
 
UBYTE cComGetNxtFile (DIR *pDir, UBYTE *pName)
 
void cComCreateBeginDl (TXBUF *pTxBuf, UBYTE *pName)
 
void cComCreateContinueDl (RXBUF *pRxBuf, TXBUF *pTxBuf)
 
void cComSystemReply (RXBUF *pRxBuf, TXBUF *pTxBuf)
 
void cComGetNameFromScandirList (struct dirent *NameList, char *pBuffer, ULONG *pNameLen, UBYTE *pFolder)
 
UBYTE cComCheckForSpace (char *pFullName, ULONG Size)
 
void cComSystemCommand (RXBUF *pRxBuf, TXBUF *pTxBuf)
 cSystemCommand More...
 
void cComUpdate (void)
 
DATA8 cComGetUsbStatus (void)
 
void cComTxUpdate (UBYTE ChNo)
 
void cComReady (void)
 opCOM_READY byte code More...
 
void cComTest (void)
 opCOM_TEST byte code More...
 
void cComRead (void)
 opCOM_READ byte code More...
 
void cComWrite (void)
 opCOM_WRITE byte code More...
 
void cComReadData (void)
 
void cComWriteData (void)
 
void cComOpenMailBox (void)
 opMAILBOX_OPEN byte code More...
 
void cComWriteMailBox (void)
 opMAILBOX_WRITE byte code More...
 
void cComReadMailBox (void)
 opMAILBOX_READ byte code More...
 
void cComTestMailBox (void)
 opMAILBOX_TEST byte code More...
 
void cComReadyMailBox (void)
 opMAILBOX_READY byte code More...
 
void cComCloseMailBox (void)
 opMAILBOX_CLOSE byte code More...
 
void cComWriteFile (void)
 
void cComGet (void)
 opCOM_GET byte code More...
 
void cComSet (void)
 opCOM_SET byte code More...
 
void cComRemove (void)
 
UBYTE cComGetBtStatus (void)
 
UBYTE cComGetWifiStatus (void)
 
void cComGetBrickName (DATA8 Length, DATA8 *pBrickName)
 
DATA8 cComGetEvent (void)
 

Variables

COM_GLOBALSgComInstance
 
UWORD UsbConUpdate = 0
 
UBYTE cComUsbDeviceConnected = FALSE
 

Macro Definition Documentation

#define SIZEOFFILESIZE   8

Definition at line 97 of file c_com.c.

#define USB_CABLE_DETECT_RATE   15000

Definition at line 81 of file c_com.c.

Enumeration Type Documentation

anonymous enum
Enumerator
FS_IDLE 

Definition at line 99 of file c_com.c.

Function Documentation

UBYTE cComCheckForSpace ( char *  pFullName,
ULONG  Size 
)

Definition at line 917 of file c_com.c.

UBYTE cComCheckUsbCable ( void  )

Definition at line 282 of file c_com.c.

RESULT cComClose ( void  )

Definition at line 213 of file c_com.c.

void cComCloseFileHandle ( SLONG pHandle)

Definition at line 512 of file c_com.c.

void cComCloseMailBox ( void  )

opMAILBOX_CLOSE byte code

Definition at line 3958 of file c_com.c.

void cComCreateBeginDl ( TXBUF pTxBuf,
UBYTE pName 
)

Definition at line 595 of file c_com.c.

void cComCreateContinueDl ( RXBUF pRxBuf,
TXBUF pTxBuf 
)

Definition at line 687 of file c_com.c.

UBYTE cComDirectCommand ( UBYTE pBuffer,
UBYTE pReply 
)

Definition at line 420 of file c_com.c.

RESULT cComExit ( void  )

Definition at line 233 of file c_com.c.

UBYTE cComFindMailbox ( UBYTE pName,
UBYTE pNo 
)

Definition at line 3243 of file c_com.c.

UBYTE cComFreeHandle ( DATA8  Handle)

Definition at line 522 of file c_com.c.

void cComGet ( void  )

opCOM_GET byte code

Definition at line 4208 of file c_com.c.

void cComGetBrickName ( DATA8  Length,
DATA8 pBrickName 
)

Definition at line 5583 of file c_com.c.

UBYTE cComGetBtStatus ( void  )

Definition at line 5557 of file c_com.c.

RESULT cComGetDeviceData ( DATA8  Layer,
DATA8  Port,
DATA8  Length,
DATA8 pType,
DATA8 pMode,
DATA8 pData 
)

Definition at line 268 of file c_com.c.

RESULT cComGetDeviceInfo ( DATA8  Length,
UBYTE pInfo 
)

Definition at line 256 of file c_com.c.

DATA8 cComGetEvent ( void  )

Definition at line 5589 of file c_com.c.

DATA8 cComGetHandle ( char *  pName)

Definition at line 542 of file c_com.c.

void cComGetNameFromScandirList ( struct dirent *  NameList,
char *  pBuffer,
ULONG pNameLen,
UBYTE pFolder 
)

Definition at line 863 of file c_com.c.

UBYTE cComGetNxtFile ( DIR pDir,
UBYTE pName 
)

Definition at line 570 of file c_com.c.

DATA8 cComGetUsbStatus ( void  )

Definition at line 2831 of file c_com.c.

UBYTE cComGetWifiStatus ( void  )

Definition at line 5563 of file c_com.c.

RESULT cComInit ( void  )

Definition at line 104 of file c_com.c.

RESULT cComOpen ( void  )

Definition at line 203 of file c_com.c.

void cComOpenMailBox ( void  )

opMAILBOX_OPEN byte code

Definition at line 3573 of file c_com.c.

void cComRead ( void  )

opCOM_READ byte code

Definition at line 3416 of file c_com.c.

UWORD cComReadBuffer ( UBYTE pBuffer,
UWORD  Size 
)

Definition at line 367 of file c_com.c.

void cComReadData ( void  )

Definition at line 3522 of file c_com.c.

void cComReadMailBox ( void  )

opMAILBOX_READ byte code

Definition at line 3781 of file c_com.c.

void cComReady ( void  )

opCOM_READY byte code

Definition at line 3281 of file c_com.c.

void cComReadyMailBox ( void  )

opMAILBOX_READY byte code

Definition at line 3923 of file c_com.c.

void cComRemove ( void  )

Definition at line 5516 of file c_com.c.

void cComSet ( void  )

opCOM_SET byte code

Definition at line 5045 of file c_com.c.

RESULT cComSetDeviceInfo ( DATA8  Length,
UBYTE pInfo 
)

Definition at line 249 of file c_com.c.

RESULT cComSetDeviceType ( DATA8  Layer,
DATA8  Port,
DATA8  Type,
DATA8  Mode 
)

Definition at line 262 of file c_com.c.

void cComSetMusbHdrcMode ( void  )

Definition at line 273 of file c_com.c.

void cComSystemCommand ( RXBUF pRxBuf,
TXBUF pTxBuf 
)

cSystemCommand

cComSystemCommand

One message at a time principles

  • The system is only able to process one command at a time (both SYS and DIR commands).
  • ComInstance.ReplyStatus holds the information about command processing.
  • Writing flag indicated that the reply is ready to be transmitted
  • Direct commands are commands to be interpreted by VM - Direct commands are not interpreted until process is returned to the VM
  • System commands are usually processed when received except for large messages (messages larger that buffersize)

Direct command -> When received -> if reply required -> ComInstance.ReplyStatus = DIR_CMD_REPLY | ---------—> if no reply required -> ComInstance.ReplyStatus = DIR_CMD_NOREPLY

VM reply to direct command -> if (ComInstance.ReplyStatus = DIR_CMD_REPLY) -> pTxBuf->Writing = 1 (VM always replies, after interp.) ComInstance.ReplyStatus = 0 | --------------—> if (ComInstance.ReplyStatus = DIR_CMD_NOREPLY) -> pTxBuf->Writing = 0 ComInstance.ReplyStatus = 0

System command -> if reply required -> ComInstance.ReplyStatus = SYS_CMD_REPLY -> if (pRxBuf->State = RXFILEDL) -> Do nothing | | | ---------------------—> if (pRxBuf->State != RXFILEDL) -> pTxBuf->Writing = 1 | ComInstance.ReplyStatus = 0 | --------------------—> If reply not req. -> ComInstance.ReplyStatus = SYS_CMD_NOREPLY -> if (pRxBuf->State = RXFILEDL) -> Do nothing | ---------------------—> if (pRxBuf->State != RXFILEDL) -> ComInstance.ReplyStatus = 0

File Download - Large messages

CONTINUE_DOWNLOAD BEGIN_DOWNLOAD —> (Message size <= Buffer size) –> Write bytes to file | –> pRxBuf->State = RXIDLE | | ------------—> (Message size > Buffer Size) –> Write bytes from buffer –> pRxBuf->State = RXFILEDL

Buffer full —> if pRxBuf->State = RXFILEDL –> Yes -> write into buffer | | | ---------------—> if Remainig msg = 0 -> pRxBuf->State = RXIDLE | ---------------—> No -> Interprete as new command

Definition at line 1037 of file c_com.c.

void cComSystemReply ( RXBUF pRxBuf,
TXBUF pTxBuf 
)

Definition at line 744 of file c_com.c.

void cComTest ( void  )

opCOM_TEST byte code

Definition at line 3350 of file c_com.c.

void cComTestMailBox ( void  )

opMAILBOX_TEST byte code

Definition at line 3891 of file c_com.c.

void cComTxUpdate ( UBYTE  ChNo)

Definition at line 2837 of file c_com.c.

void cComUpdate ( void  )

Definition at line 2448 of file c_com.c.

void cComWrite ( void  )

opCOM_WRITE byte code

Definition at line 3472 of file c_com.c.

UWORD cComWriteBuffer ( UBYTE pBuffer,
UWORD  Size 
)

Definition at line 395 of file c_com.c.

void cComWriteData ( void  )

Definition at line 3536 of file c_com.c.

void cComWriteFile ( void  )

Definition at line 3970 of file c_com.c.

void cComWriteMailBox ( void  )

opMAILBOX_WRITE byte code

Definition at line 3628 of file c_com.c.

COM_GLOBALS* getComInstance ( )

Definition at line 75 of file c_com.c.

void setComInstance ( COM_GLOBALS _Instance)

Definition at line 70 of file c_com.c.

Variable Documentation

UBYTE cComUsbDeviceConnected = FALSE

Definition at line 84 of file c_com.c.

COM_GLOBALS* gComInstance

Definition at line 68 of file c_com.c.

UWORD UsbConUpdate = 0

Definition at line 83 of file c_com.c.