Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 309219 Details for
Bug 445211
[RFE] DTR/DSR flow control
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
test case
testcase2.c (text/plain), 5.04 KB, created by
Aristeu Rozanski
on 2008-06-13 14:49:49 UTC
(
hide
)
Description:
test case
Filename:
MIME Type:
Creator:
Aristeu Rozanski
Created:
2008-06-13 14:49:49 UTC
Size:
5.04 KB
patch
obsolete
>#include <stdio.h> >#include <fcntl.h> >#include <unistd.h> >#include <termios.h> >#include <string.h> >#include <errno.h> >#include <sys/types.h> > >#define CDTRDSR 004000000000 > > >static void show_help(FILE *out) >{ > fprintf(out, "testcase -d <device file>\n"); >} > >#define p(x...) do { printf(x); fflush(stdout); } while(0) >static int write_to_printer(char *desc, int fd, const char *data, int size) >{ > int rc, s = size; > const char *d = data; > > p(desc); > > if (size == -1) > s = size = strlen(data); > > while(1) { > rc = write(fd, d, s); > if (rc == s) > break; > if (rc < 0) { > perror("writing to serial"); > if (errno == EAGAIN || errno == EINTR) > continue; > return 1; > } > d += rc; > s -= rc; > } > return 0; >} > >#if 0 >PRINT #1, CHR$(&H1B);"@"; 'Initializes the printer (ESC @) >PRINT #1, CHR$(&H1B);"a";CHR$(1); 'Specifies a centered printing position (ESC a) >PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Specifies font A (ESC !) >PRINT #1, "January 14, 2002 15:00"; >PRINT #1, CHR$(&H1B);"d";CHR$(3); 'Prints and 3 line feeding (ESC d) >PRINT #1, CHR$(&H1B);"a";CHR$(0); 'Selects the left print position (ESC a) >PRINT #1, CHR$(&H1B);"!";CHR$(1); 'Selects font B >PRINT #1, "TM-U210B $20.00"; CHR$(&HA); >PRINT #1, "TM-U210D $21.00"; CHR$(&HA); >PRINT #1, "PS-170 $17.00"; CHR$(&HA); >PRINT #1, CHR$(&HA); 'Line feeding (LF) >PRINT #1, CHR$(&H1B);"!";CHR$(17); 'Selects double-height mode >PRINT #1, "TOTAL $58.00"; CHR$(&HA); >PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Cancels double-height mode >PRINT #1, "------------------------------"; CHR$(&HA); >PRINT #1, "PAID $60.00"; CHR$(&HA); >PRINT #1, "CHANGE $ 2.00"; CHR$(&HA); >PRINT #1, CHR$(&H1D);"V";CHR$(66);CHR$(0); 'Feeds paper & cut >' Drawer Kick (ESC p) >PRINT #1, CHR$(&H1B); CHR$(&H70); CHR$(&H0); CHR$(60); CHR$(120); >#endif > >const char ESC_init[] = { 0x1B, '@' }; >const char ESC_center[] = { 0x1B, 'a', 1 }; >const char ESC_fontA[] = { 0x1B, '!', 0 }; >const char ESC_3line[] = { 0x1B, 'd', 3 }; >const char ESC_leftal[] = { 0x1B, 'a', 0 }; >const char ESC_fontB[] = { 0x1B, '!', 1 }; >const char ESC_dheighton[] = { 0x1B, '!', 17 }; >const char ESC_feedncut[] = { 0x1B, 'V', 66, 0 }; >const char ESC_drawer[] = { 0x1B, 0x70, 0, 60, 120 }; >static void do_test(int fd) >{ > if (write_to_printer("Initializing printer\n", fd, ESC_init, 2) || > write_to_printer("Centering position\n", fd, ESC_center, 3) || > write_to_printer("Selecting font A\n", fd, ESC_fontA, 3) || > write_to_printer("Printing date\n", fd, "January 14, 2002 15:00", -1) || > write_to_printer("3 line feeding\n", fd , ESC_3line, 3) || > write_to_printer("Selects left alignment\n", fd, ESC_leftal, 3) || > write_to_printer("Selects font B\n", fd, ESC_fontB, 3) || > write_to_printer("Printing first item\n", fd, "TM-U210B $20.00\n", -1) || > write_to_printer("Printing second item\n", fd, "TM-U210D $21.00\n", -1) || > write_to_printer("Printing third item\n", fd, "PS-170 $17.00\n", -1) || > write_to_printer("Line feeding\n", fd, "\n", -1) || > write_to_printer("Selects double-height mode\n", fd, ESC_dheighton, 3) || > write_to_printer("Printing total\n", fd, "TOTAL $58.00\n", -1) || > write_to_printer("Cancels double-height mode\n", fd, ESC_fontA, 3) || > write_to_printer("Printing line\n", fd, "------------------------------\n", -1) || > write_to_printer("Printing Paid line\n", fd, "PAID $60.00\n", -1) || > write_to_printer("Printing change\n", fd, "CHANGE $ 2.00\n", -1) || > write_to_printer("Feeds paper and cut\n", fd, ESC_feedncut, 4) || > write_to_printer("Drawer\n", fd, ESC_drawer, 5)) > return; >} > >static const char *options = "d:h"; >int main(int argc, char *argv[]) >{ > char *file = NULL; > int opt, fd; > struct termios tio; > > do { > opt = getopt(argc, argv, options); > switch(opt) { > case 'd': > file = strdup(optarg); > break; > case 'h': > show_help(stdout); > return 0; > case -1: > break; > default: > show_help(stderr); > return 1; > } > } while (opt >= 0); > > if (file == NULL) { > fprintf(stderr, "you must specify a device with -d\n"); > show_help(stderr); > return 1; > } > > fd = open(file, O_RDWR); > if (fd < 0) { > fprintf(stderr, "Error opening file %s: %s\n", file, > strerror(errno)); > return 1; > } > > if (tcgetattr(fd, &tio) == -1) { > perror("Error getting terminal attributes"); > close(fd); > return 1; > } > > /* testing if the new bit works */ > tio.c_cflag &= ~CRTSCTS; > tio.c_cflag |= CDTRDSR; > if (tcsetattr(fd, TCSANOW, &tio) == -1) { > fprintf(stderr, "Error enabling CDTRDSR (%s). Is this a " > "patched kernel?\n", strerror(errno)); > close(fd); > return 1; > } > > /* resetting the flags */ > tio.c_cflag &= ~CDTRDSR; > tio.c_iflag &= ~(IXON | IXOFF); > if (cfsetspeed(&tio, B115200) == -1) { > perror("Error setting speed"); > close(fd); > return errno; > } > cfmakeraw(&tio); > tio.c_cflag |= CDTRDSR; > if (tcsetattr(fd, TCSANOW, &tio) == -1) { > perror("Error resetting flags"); > close(fd); > return errno; > } > > do_test(fd); > > return 0; >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 445211
:
308359
|
308360
|
309219
|
309849
|
315299
|
315300
|
315301