Home > Software engineering >  Refer new DLL serial communication problems
Refer new DLL serial communication problems

Time:09-23

On the basis of a DLL export data to increase the function of the data from serial port (Sn via a serial port to send out), refer to the great god what to change, attach the current data exported DLL source files, online etc.!


//CommData. CPP: defines the DLL export function of the application, 
//

# include "stdafx. H"

# pragma once
# ifdef Data_API
# the else
# define Data_API extern "C" _declspec (dllimport)
# endif

#include
#include
#include
#include
using namespace std;


//send the product scan to data,
//parameter Mo work order number (note: if the user does not change the work order number within the production file, the default for the machine number)
//Sn scan parameters to an array of data
//parameter snNum scanning to the number of data format for: SN1, SN2, SN3==3

//the return value//return TRUE success/failure returns FALSE
Data_API bool SenScanData (string Mo, a string of Sn [], int snNum);

Bool SenScanData (string Mo, a string of Sn [], int snNum)
{

return TRUE;
}
//parameter 1 dlgData extra interface data
//parameter 3 machineData machine data

//PrName system program
//StarTime start homework time 2017/9/5 13:30
//StopTime 2017/9/5 end homework time comes to
//MNum number
//CodeType
//parameter 2 addDataNum additional data quantity
Data_API bool SenData (string dlgData [], string machineData [], string Sn [], int snNum, string FilePath);
Bool SenData (string dlgData [], string machineData [], string Sn [], int snNum, string FilePath)
{
//General1=
string str;
Ofstream ofst;
Ofst. Open (FilePath, the ios: : app);
STR="General1=" + dlgData [1]. No.//work order
Ofst & lt; STR="\ nGeneral2=" + dlgData [2].//process
Ofst & lt; STR="\ nGeneral3=" + machineData [2].//start time
Ofst & lt; STR="\ nGeneral4=" + machineData [3].//end time
Ofst & lt; STR="\ nGeneral5=" + dlgData [0].//the machine number
Ofst & lt; STR="\ nGeneral6=" + dlgData [3].//CODE type
Ofst & lt; STR="\ nGeneral7=" + Sn [0].//barcode
for(int i=1; I<(snNum - 1); I++)
{
STR=STR + ", "+ Sn [I + 1);
}
Ofst & lt;
STR="\ nGeneral8=" + machineData [0].//the program name
Ofst & lt; STR="\ nGeneral9=" + dlgData [4].//homework quantity (the amount of total production)
Ofst & lt;
STR="\ nGeneral10=" + machineData [4].//which one products
Ofst & lt;
STR="\ nGeneral11=" + machineData [1]. No.//operators
Ofst & lt;
STR="\ nGeneral12=" + dlgData [5].//smelting equipment number
Ofst & lt;
STR="\ nGeneral13=" + machineData [5]. Positive and negative//
Ofst & lt; STR="\ nGeneral14=" + machineData [6].//PCS serial number
Ofst & lt;
STR="\ nMachine1=" + machineData [7].//this board posted several points in total,
Ofst & lt; STR="\ nMachine2=" + dlgData [6].//number of auxiliary number 1
Ofst & lt; STR="\ nMachine3=" + dlgData [7].//number of auxiliary number 2

Ofst & lt; STR="\ nMachine4=" + dlgData [8].//suction nozzle number 1
Ofst & lt; STR="\ nMachine5=" + dlgData [9].//suction nozzle number 2
Ofst & lt; STR="\ nMachine6=" + machineData [8].//extractor number
Ofst & lt; STR="\ nMachine7=" + machineData [9].//extractor rate
Ofst & lt;
Ofst. Close ();
OutputDebugString (" Dll output complete ");
return true;
}

CodePudding user response:

Serial Communications in Win32
Serial Communications,

CodePudding user response:

Using SenData function can ah

CodePudding user response:

refer to the second floor xianglitian response:
using SenData function can ah

You mean this function can be achieved in the code? For detailed guidance

CodePudding user response:

Do you want in SenScanData function implementation send sn number, you need to open the serial port, serial port configuration. After send the sn number, and then close the serial port, under Windows specific practices:
CreateFile created a serial port, SetCommState set properties, WriteFile send data, CloseHandle to close a serial port,
Specific code can be found online, you can check it,

CodePudding user response:

The upstairs, parameters must be configured properly

CodePudding user response:

Is mainly operating method of the serial port, and then put data into a BYTE array, etc
  • Related