#include "pch.h"
#include "framework.h"
#include "CommSDK.h"
#include "TcpComm.h"
|
DLLEXINT | BytesAvailable () |
| 取得可讀取資料數量 (bytes)
|
|
DLLEXBOOL | Connected () |
| 印表機是否處於連接狀態
|
|
DLLEXVOID | Read (byte *buffer, int size) |
| 從印表機讀取資料
|
|
DLLEXVOID | Write (byte *dataOut, int iDataSize) |
| 寫入資料至印表機
|
|
DLLEXPBYTE | WriteAndWaitForResponse (byte *dataOut, int iDataSize, int responseStartTimeOut, int responseEndTimeOut, char *completetionToken) |
| 將位元資料寫入輸出流並返回接收到的資料,返回的資料是任何接收到的資料,或者如果收到完成標誌則返回至該標誌的資料,在返回之前等待回應超時。
|
|
DLLEXVOID | Close () |
| 從印表機斷開連線
|
|
DLLEXVOID | Open () |
| 透過 NET 介面開啟印表機
|
|
DLLEXVOID | SendPrintFile (char *ipAddress, char *fileName) |
| 透過 NET 介面寫入檔案至印表機
|
|
DLLEXVOID | SendPrintString (char *ipAddress, char *data, int iDataSize) |
| 透過 NET 介面寫入字串至印表機
|
|
DLLEXVOID | TcpConnect (char *ipAddress, int port) |
| 透過 NET 連接所選擇的印表機
|
|
DLLEXVOID | GetComm (CObject *&ptrComm) |
| 取得印表機目前使用的連接介面
|
|
◆ COMM_IDX
◆ BytesAvailable()
取得可讀取資料數量 (bytes)
- 傳回值
- 大於 0 : 可讀取的資料數量
等於 0 : 無資料
- 程式碼
pBuf = new byte[iBytes];
DLLEXINT BytesAvailable()
取得可讀取資料數量 (bytes)
Definition CommSDK.cpp:144
DLLEXVOID Read(byte *buffer, int size)
從印表機讀取資料
Definition CommSDK.cpp:272
◆ Close()
從印表機斷開連線
- 傳回值
- 無
- 程式碼
DLLEXVOID Close()
從印表機斷開連線
Definition CommSDK.cpp:502
◆ Connected()
印表機是否處於連接狀態
- 傳回值
- 真 (連接) or 假 (沒連接)
- 程式碼
DLLEXBOOL Connected()
印表機是否處於連接狀態
Definition CommSDK.cpp:190
◆ GetComm()
取得印表機目前使用的連接介面
- 參數
-
- 傳回值
- 無
- 程式碼
CObject* commPtr = NULL;
DLLEXVOID GetComm(CObject *&ptrComm)
取得印表機目前使用的連接介面
Definition CommSDK.cpp:744
◆ Open()
透過 NET 介面開啟印表機
- 傳回值
- 無
- 程式碼
DLLEXVOID Open()
透過 NET 介面開啟印表機
Definition CommSDK.cpp:542
◆ Read()
從印表機讀取資料
- 參數
-
[in] | buffer | : 儲存資料的緩衝區 |
[in] | size | : 緩衝區大小 |
- 傳回值
- 無
- 程式碼
-
◆ SendPrintFile()
DLLEXVOID SendPrintFile |
( |
char * | ipAddress, |
|
|
char * | fileName ) |
透過 NET 介面寫入檔案至印表機
- 參數
-
[in] | ipAddress | : 印表機的IP位址 |
[in] | fileName | : 檔案路徑 |
- 傳回值
- 無
- 程式碼
DLLEXVOID SendPrintFile(char *ipAddress, char *fileName)
透過 NET 介面寫入檔案至印表機
Definition CommSDK.cpp:603
◆ SendPrintString()
DLLEXVOID SendPrintString |
( |
char * | ipAddress, |
|
|
char * | data, |
|
|
int | iDataSize ) |
透過 NET 介面寫入字串至印表機
- 參數
-
[in] | ipAddress | : 印表機的IP位址 |
[in] | data | : 待寫入的資料 |
[in] | iDataSize | : 寫入的資料量 |
- 傳回值
- 無
- 程式碼
SendPrintString((
char*)
"10.0.10.172", (
char*)
"FEED 100", strlen(
"FEED 100"));
DLLEXVOID SendPrintString(char *ipAddress, char *data, int iDataSize)
透過 NET 介面寫入字串至印表機
Definition CommSDK.cpp:648
◆ TcpConnect()
DLLEXVOID TcpConnect |
( |
char * | ipAddress, |
|
|
int | port ) |
透過 NET 連接所選擇的印表機
- 參數
-
[in] | ipAddress | : 印表機的IP位址 |
[in] | port | : 印表機的埠號 |
- 傳回值
- 無
- 程式碼
DLLEXVOID TcpConnect(char *ipAddress, int port)
透過 NET 連接所選擇的印表機
Definition CommSDK.cpp:691
◆ Write()
DLLEXVOID Write |
( |
byte * | dataOut, |
|
|
int | iDataSize ) |
寫入資料至印表機
- 參數
-
[in] | dataOut | : 待寫入的資料 |
[in] | iDataSize | : 寫入的資料量 |
- 傳回值
- 無
- 程式碼
std::string content;
content += "FEED 100";
const char* pStr = content.c_str();
Write((
byte*)pStr, strlen(pStr));
DLLEXVOID Write(byte *dataOut, int iDataSize)
寫入資料至印表機
Definition CommSDK.cpp:355
◆ WriteAndWaitForResponse()
DLLEXPBYTE WriteAndWaitForResponse |
( |
byte * | dataOut, |
|
|
int | iDataSize, |
|
|
int | responseStartTimeOut, |
|
|
int | responseEndTimeOut, |
|
|
char * | completetionToken ) |
將位元資料寫入輸出流並返回接收到的資料,返回的資料是任何接收到的資料,或者如果收到完成標誌則返回至該標誌的資料,在返回之前等待回應超時。
- 參數
-
[in] | dataOut | : 待寫入印表機的資料 |
[in] | iDataSize | : 寫入的資料量 |
[in] | responseStartTimeOut | : 等待接收第一筆資料的超時時間。這是從開始等待到接收到第一個位元資料所花費的時間 |
[in] | responseEndTimeOut | : 當未收到新資料時的超時時間。這是從接收到最後一個位元資料後開始計算的時間。 |
[in] | completetionToken | 表示預期回應結束的字串標誌。如果只是想在將資料寫入連接後等待回應,這個字串可以是空字串。 |
- 傳回值
- byte* 從連接中接收到的字串。 返回的資料是任何接收到的資料,或者如果收到完成標誌 (completionToken),則返回至該標誌為止的資料。
- 程式碼
std::string content;
content += "FEED 100\r\n";
content += "OUT \"12345678\"\r\n";
std::cout << std::endl;
std::cout << "Send to Printer:" << std::endl;
std::cout << content;
const char* pStr = content.c_str();
DLLEXPBYTE WriteAndWaitForResponse(byte *dataOut, int iDataSize, int responseStartTimeOut, int responseEndTimeOut, char *completetionToken)
將位元資料寫入輸出流並返回接收到的資料,返回的資料是任何接收到的資料,或者如果收到完成標誌則返回至該標誌的資料,在返回之前等待回應超時。
Definition CommSDK.cpp:448
◆ giComm
◆ gTcpComm
◆ gTcpConnection
TcpConnection gTcpConnection |
◆ theApp