Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to read a serial port by using api calls createfile, readfile, getcommstate, setcommstate etc...

this all requires the proper declaration of a structure "dcb"

typedef struct _DCB {
 DWORD DCBlength;
 DWORD BaudRate;
 DWORD fBinary  :1;
 DWORD fParity  :1;
 DWORD fOutxCtsFlow  :1;
 DWORD fOutxDsrFlow  :1;
 DWORD fDtrControl  :2;
 DWORD fDsrSensitivity  :1;
 DWORD fTXContinueOnXoff  :1;
 DWORD fOutX  :1;
 DWORD fInX  :1;
 DWORD fErrorChar  :1;
 DWORD fNull  :1;
 DWORD fRtsControl  :2;
 DWORD fAbortOnError  :1;
 DWORD fDummy2  :17;
 WORD  wReserved;
 WORD  XonLim;
 WORD  XoffLim;
 BYTE  ByteSize;
 BYTE  Parity;
 BYTE  StopBits;
 char  XonChar;
 char  XoffChar;
 char  ErrorChar;
 char  EofChar;
 char  EvtChar;
 WORD  wReserved1;
} DCB, *LPDCB;

My first question is how would you declare this in mapbasic? Then how to determine the structures length?

share|improve this question

1 Answer 1

DWORD = Integer (32-bit signed) WORD = SmallInt (16-bit signed) BYTE do not exist in mapbasic. CHAR may be done as string*1

You have to create another DLL, that sits between mapbasic and your DLL. This DLL should translate to a record format, where Mapbasic understands all the fields.

share|improve this answer
    
thanks for your response, can you explain further about these DLL's and how this might work, thanks –  P Thomas Nov 15 '11 at 21:13
    
I have assumed this _DCB structure is part of DLL function calls? Since it uses types that mapbasic do not support, you need to write a DLL, that sits as a proxy between the DLL and mapbasic. This should remap the data structure into one that mapbasic understands. That is changing BYTES to WORDS etc. –  Uffe Kousgaard Nov 16 '11 at 10:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.