Example Code
The following examples are written in MS Visual Basic V3 for Windows using the serial communications control (MSCOMM.VBX). It can be used as a guide in implementing iPort/AFM interface programs in other programming languages and operating environments.
Note: This example code is available online at:
iPort/AFM Reset |
|
Comm1.Output = Chr$(18) | 'Ctrl/R |
Comm1.Output = Chr$(18) | 'Ctrl/R |
Comm1.Output = Chr$(18) | 'Ctrl/R |
iPort/AFM Initialization |
|
Comm1.Output = "/f0" | 'Set iPort/AFM XON/XOFF Flow Control |
Comm1.Output = Chr$(13) |
|
Comm1.Output = "/i70" | 'Set iPort/AFM’s Own Slave Address |
Comm1.Output = Chr$(13) |
|
Comm1.Output = "/d4e" | 'Set Destination Slave Address |
Comm1.Output = Chr$(13) |
|
Comm1.Output = "/o" | 'Open I2C Connection |
Comm1.Output = Chr$(13) |
|
Master Transmit Message |
|
Comm1.Output = "/T~00~01" | 'Send Master Tx Command |
Comm1.Output = Chr$(13) | 'Terminate Command |
Master Receive Message |
|
Comm1.Output = "/R10" | 'Send Master Rx Command |
Comm1.Output = Chr$(13) | 'Terminate Command |
Communication Event Processing
Static Sub Comm1_OnComm ()
Static LineBuf$
While Comm1.InBufferCount
Msg$ = Comm1.Input ' Get Comm input character
CharIn$ = Msg$
50