Epson E02 manual For Linux, Rev. a 13Programming Samples

Page 71

UB-E02 Technical Reference Guide

4.7.8.2 For Linux

/* UDP3289 programming sample for LINUX

*HOW TO BUILD

*cc ludp.c

*/

#include <stdio.h> #include <netdb.h>

#define MAXBUF 512 char buf[MAXBUF];

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

{

int sock;

struct sockaddr_in addr; int i, len;

socklen_t fromlen;

if (argc != 2) {

printf("usage: udp3289 IP_ADDRESS\n"); exit(1);

}

/* create sockets */

sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) {

perror("socket()");

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 buf[11] = 0x00;

buf[12] = 0x00; // parameter length Length

Rev. A

4-13Programming Samples

Image 71
Contents UB-E02 Technical Reference Guide Page Rev. a Revision Information Related Documents Contents of the GuideAbout This Guide For Canadian Users EMC and Safety Standards AppliedCE Marking FCC Compliance Statement For American UsersGereäuschpegel Key to SymbolsLabel Safety PrecautionsProduct Servicing Supported Operating Systems Environments for Setup UtilityIntroduction Operating EnvironmentsSupported TM Printers Appendix How to Use this GuideInstallation Overview ProgrammingContents Rev. a Contents Xii Contents Rev. a Supported Network Protocols Supported Operating SystemsOther Limitations Installation Precautions InstallationFunctions SwitchUnpacking Part NamesUB-E02 Installation 4Installation Rev. a Page 6Installation Rev. a UB-E02 Status Sheet Printing Initializing UB-E023 Q3. Starting up the printer takes a long time FAQ2 Q2. The self test does not operate correctly UB-E02 Technical Reference Guide 10Installation Rev. a Setting the TCP/IP protocol in Your Operating System Setting the IP AddressSetting the IP Address using Epson TMNet WinConfig 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 Time-out for Connection Commands Sent to a TM Printer When the Power is OnMonitoring of the ASB status Priorities of PrintingCommands Packets Printer Operation by the UDP CommandsReply data 2 03-0000 Retrieving Basic Information3 03-0010 Retrieving Status Set-up data 5 03-0012 Reset4 03-0011 Forced Transmission 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 Overview FeaturesPrinter Connection Line Display ConnectionHardware Specifications Printing Communications Protocols Software SpecificationsExternal appearance and connector locations Basic Communications ProtocolsSnmp MIB Status Inquiry and Setting ProtocolsHttp IP Address Acquisition by Dhcp Automatic IP Address Assignment ProtocolsEnpc IP Address Assignment by Apipa Manual SettingItem List Internal SettingsSetting the IP Address with arp + ping Internal Parameter Setting MethodsSetting with Exclusive utility Setting with BrowserSupported protocol Upgrade MethodsInitializing Version UpgradingStorage Conditions Environmental SpecificationsDefinitions 2Definitions Rev. a Page Epson