2.13 Communications with a Windows PC (Visual C++ Application)
Using Automatic Reception with the MP3000 as a Slave
2-347
namespace VC_SAMPLE
{
*
*
// Functions and variables referenced from external files
extern "C"{
extern int memobus_master_main( unsigned short trans_prt, unsigned long myip,
unsigned short myport, unsigned long dstip, unsigned
short dstport );
extern int memobus_msg( unsigned short trans_prt, unsigned char
∗
sbuf, unsigned char
∗
rbuf
);
extern void mk_cmd_data( unsigned char SFC, unsigned char CPUNum, unsigned short
Adr,
unsigned short DataNum, unsigned char∗
sbuf );
}
private: System::Void Command1_Click(System::Object ∗ sender, System::EventArgs ∗ e)
{
unsigned long MyIP, DstIP;
unsigned short MyPort, DstPort;
int rc;
// Get the PC’s IP address
// Add code to get the IP address from TextBox1, TextBox2, TextBox3, and TextBox4.
// Example: MyIP: 0x0501A8C0 (192.168.1.5)