Epson E02 manual Programming Sample, For Windows Console

Page 69

UB-E02 Technical Reference Guide

4.7.8 Programming Sample

4.7.8.1 For Windows Console

/* UDP3289 programming sample for win32

*HOW TO BUILD

*cc wudp.cpp wsock32.lib

*/

#include <stdio.h> #include <winsock.h>

#define MAXBUF 512 char buf[MAXBUF];

int main(int argc, char* argv[])

{

WSADATA data; SOCKET sock;

struct sockaddr_in addr; int i, len, fromlen;

if (argc != 2) {

printf("usage: wudp <IP address>\n"); exit(1);

}

/* initialize windows socket */ WSAStartup(0x0101, &data);

/* Create socket */

if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET) { fprintf(stderr, "Error socket(): %d\n", WSAGetLastError());

exit(1);

}

/* initialize the parameter */ memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(3289); addr.sin_addr.s_addr = inet_addr(argv[1]);

/* make a packet (PRINTER STATUS) */

buf[0]

= 'E';

buf[1]

= 'P';

buf[2]

= 'S';

buf[3]

= 'O';

buf[4]

= 'N';

buf[5]

= 'Q'; // PacketType(Q)

buf[6]

= 0x03; // DeviceType(3)

buf[7]

= 0x00; // DeviceNumber(0)

buf[8]

= 0x00; // Function(0010h)

buf[9]

= 0x10;

buf[10] = 0x00; // Result

Rev. A

4-11Programming Samples

Image 69
Contents UB-E02 Technical Reference Guide Page Rev. a Revision Information Contents of the Guide About This GuideRelated Documents CE Marking EMC and Safety Standards AppliedFCC Compliance Statement For American Users For Canadian UsersGereäuschpegel Key to SymbolsSafety Precautions Product ServicingLabel Introduction Environments for Setup UtilityOperating Environments Supported Operating SystemsSupported TM Printers Installation Overview How to Use this GuideProgramming AppendixContents Rev. a Contents Xii Contents Rev. a Supported Network Protocols Supported Operating SystemsOther Limitations Installation Precautions InstallationUnpacking SwitchPart Names FunctionsUB-E02 Installation 4Installation Rev. a Page 6Installation Rev. a UB-E02 Status Sheet Printing Initializing UB-E02FAQ 2 Q2. The self test does not operate correctly3 Q3. Starting up the printer takes a long time UB-E02 Technical Reference Guide 10Installation Rev. a Setting the IP Address Setting the IP Address using Epson TMNet WinConfigSetting the TCP/IP protocol in Your Operating System Windows UB-E02 Technical Reference Guide Windows NT Windows Installation Environments Installing Epson TMNet WinConfigInstallation with Windows Setting with the Epson TMNet WinConfig UB-E02 Technical Reference Guide Page Setting the IP Address Using the arp/ping Command Example ping Epson TMNet WinConfig Functions Menu Bar Tool Menu Time-out settingSearch Options Settings Printer Print server TCP/IP Password Opening Screen Epson TMNet WebConfig FunctionsTCP/IP General Information Protocol Information and SettingsApipa 2.2 TCP/IP InformationSnmp Information 2.4 TCP/IP Setting Snmp Communication Setting Snmp IP Trap 1 Setting Snmp IP Trap 2 Setting Administrator Setting Password Setting Reset Advanced Programming Samples Buffer of the UB-E02 Method of Printing to the UB-E02For Windows Console Direct Printing by PORT91004Programming Samples For Linux Monitoring of the ASB status Commands Sent to a TM Printer When the Power is OnPriorities of Printing Time-out for ConnectionCommands Packets Printer Operation by the UDP Commands2 03-0000 Retrieving Basic Information 3 03-0010 Retrieving StatusReply data 5 03-0012 Reset 4 03-0011 Forced TransmissionSet-up data 6 03-0013 Buffer Flash 7 03-0016 Clearing Connection Time-Out TimerFor Windows Console Programming Sample12Programming Samples Rev. a 13Programming Samples For Linux14Programming Samples Printer Connection FeaturesLine Display Connection OverviewHardware Specifications External appearance and connector locations Software SpecificationsBasic Communications Protocols Printing Communications ProtocolsStatus Inquiry and Setting Protocols HttpSnmp MIB Automatic IP Address Assignment Protocols EnpcIP Address Acquisition by Dhcp IP Address Assignment by Apipa Manual SettingItem List Internal SettingsSetting with Exclusive utility Internal Parameter Setting MethodsSetting with Browser Setting the IP Address with arp + pingInitializing Upgrade MethodsVersion Upgrading Supported protocolStorage Conditions Environmental SpecificationsDefinitions 2Definitions Rev. a Page Epson