Skip to content

Commit 1a8a336

Browse files
author
Alastair M. Robinson
committed
Fixed build issues with test programs, added sendserial and rs232wrapper
1 parent 326cfc4 commit 1a8a336

10 files changed

+348
-16
lines changed

Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ check_PROGRAMS = dirtreetest jpegscan jpegcheck \
1313
composite imgsrctest \
1414
combotest tabui \
1515
printqueuetest stpuitest debugtest errorqueuetest \
16-
smartptrtest imgsinktest
16+
smartptrtest imgsinktest sendserial
1717

1818

1919
bin_PROGRAMS = threadtest gprintertest mkthumbnail profileuitest pvtest configtest mmmenugfx misctest
2020

21+
sendserial_SOURCES = sendserial.cpp
2122
misctest_SOURCES = misctest.cpp
2223
mmmenugfx_SOURCES = mmmenugfx.cpp
2324
configtest_SOURCES = configtest.cpp

combotest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
#include <gtk/gtk.h>
66

7+
#include "config.h"
78
#include "miscwidgets/simplecombo.h"
89
#include "breakhandler.h"
9-
#include "config.h"
1010
#include "gettext.h"
1111
#define _(x) gettext(x)
1212

errorqueuetest.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <iostream>
22

3+
#include "config.h"
34
#include "miscwidgets/errordialogqueue.h"
45

56

imgsrctest.cpp

+45-12
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,22 @@ class ImageSource_RainbowSweep : public ImageSource
3434
{
3535
public:
3636
ImageSource_RainbowSweep(int width,int height)
37-
: ImageSource(width,height,IS_TYPE_RGB)
38-
{
39-
randomaccess=true;
40-
MakeRowBuffer();
37+
: ImageSource(width,height,IS_TYPE_RGB)
38+
{
39+
randomaccess=true;
40+
MakeRowBuffer();
4141
}
42-
~ImageSource_RainbowSweep()
42+
43+
~ImageSource_RainbowSweep()
4344
{
4445
}
4546

4647
ISDataType *GetRow(int row)
4748
{
48-
if(currentrow==row)
49-
return(rowbuffer);
50-
double a=row;
49+
if(currentrow==row)
50+
return(rowbuffer);
51+
52+
double a=row;
5153
a/=height;
5254

5355
for(int x=0;x<width;++x)
@@ -80,9 +82,9 @@ class ImageSource_RainbowSweep : public ImageSource
8082
rowbuffer[x*3+1]=EIGHTTOIS(g);
8183
rowbuffer[x*3+2]=EIGHTTOIS(b);
8284
}
83-
84-
currentrow=row;
85-
return(rowbuffer);
85+
86+
currentrow=row;
87+
return(rowbuffer);
8688
}
8789
};
8890

@@ -105,7 +107,7 @@ int main(int argc,char **argv)
105107
}
106108
#endif
107109

108-
#if 1
110+
#if 0
109111

110112
class Test : public ConfigFile, public ProfileManager
111113
{
@@ -510,3 +512,34 @@ int main(int argc,char **argv)
510512
}
511513
#endif
512514

515+
516+
int main(int argc,char **argv)
517+
{
518+
try
519+
{
520+
if(argc<2)
521+
return(0);
522+
ImageSource *is=ISLoadImage(argv[1]);
523+
cerr << "File has " << is->samplesperpixel << " spp"<< std::endl;
524+
for(int y=0;y<is->height;++y)
525+
{
526+
ISDataType *row=is->GetRow(y);
527+
for(int x=0;x<is->width;++x)
528+
{
529+
ISDataType r,g,b;
530+
r=*row++;
531+
g=*row++;
532+
b=*row++;
533+
int out=(r&0xf800)|((g>>5)&0x0Fe0)|((b>>11)&0x1f);
534+
putc(out>>8,stdout);
535+
putc(out&255,stdout);
536+
}
537+
}
538+
}
539+
catch(const char *err)
540+
{
541+
cerr << "Error: " << err << endl;
542+
}
543+
return(0);
544+
}
545+

sendserial.cpp

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#include <iostream>
2+
3+
#include <getopt.h>
4+
5+
#include "rs232wrapper.h"
6+
#include "binaryblob.h"
7+
8+
#include "debug.h"
9+
10+
#include "config.h"
11+
12+
class SendSerial_Options
13+
{
14+
public:
15+
SendSerial_Options(int argc,char **argv) : serdevice("/dev/ttyUSB0")
16+
{
17+
ParseOptions(argc,argv);
18+
}
19+
void ParseOptions(int argc,char **argv)
20+
{
21+
static struct option long_options[] =
22+
{
23+
{"help",no_argument,NULL,'h'},
24+
{"version",no_argument,NULL,'v'},
25+
{"serdevice",required_argument,NULL,'s'},
26+
{"debug",required_argument,NULL,'d'},
27+
{0, 0, 0, 0}
28+
};
29+
30+
while(1)
31+
{
32+
int c;
33+
c = getopt_long(argc,argv,"hvs:d:",long_options,NULL);
34+
if(c==-1)
35+
break;
36+
switch (c)
37+
{
38+
case 'h':
39+
printf("Usage: %s [options] image1 [image2] ... \n",argv[0]);
40+
printf("\t -h --help\t\tdisplay this message\n");
41+
printf("\t -v --version\t\tdisplay version\n");
42+
printf("\t -s --serdevice\t\tspecify device node for serial comms\n");
43+
printf("\t -d --debug\t\tset debug level (0 for errors only, 4 for verbose output)\n");
44+
throw 0;
45+
break;
46+
case 'v':
47+
printf("%s\n",PACKAGE_STRING);
48+
throw 0;
49+
break;
50+
case 's':
51+
serdevice=optarg;
52+
break;
53+
case 'd':
54+
Debug.SetLevel(DebugLevel(atoi(optarg)));
55+
break;
56+
}
57+
}
58+
}
59+
protected:
60+
std::string serdevice;
61+
std::string watchdir;
62+
bool wait;
63+
};
64+
65+
66+
class SerialStream : public SendSerial_Options, public RS232Wrapper
67+
{
68+
public:
69+
SerialStream(int argc,char **argv) : SendSerial_Options(argc,argv), RS232Wrapper(serdevice)
70+
{
71+
}
72+
~SerialStream()
73+
{
74+
}
75+
void SendFile(const char *fn)
76+
{
77+
BinaryBlob blob(fn);
78+
size_t l=blob.GetSize();
79+
char *p=blob.GetPointer();
80+
Write(p,l);
81+
}
82+
};
83+
84+
85+
int main(int argc,char **argv)
86+
{
87+
Debug.SetLevel(TRACE);
88+
89+
try
90+
{
91+
SerialStream stream(argc,argv);
92+
for(int i=optind;i<argc;++i)
93+
stream.SendFile(argv[i]);
94+
return(0);
95+
}
96+
catch(const char *err)
97+
{
98+
Debug[ERROR] << "Error: " << err << std::endl;
99+
}
100+
catch(int rc)
101+
{
102+
return(rc);
103+
}
104+
return(0);
105+
}
106+

smartptrtest.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include <iostream>
22
#include <cstring>
33
#include <memory>
4+
#include <cstdlib>
5+
6+
#include "config.h"
7+
48
#include "debug.h"
59
#include "thread.h"
610

stpuitest.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <iostream>
22

3+
#include "config.h"
4+
35
#include "gutenprint/gutenprint.h"
46
#include "stpui_widgets/stpui_optionbook.h"
57
#include "stpui_widgets/stpui_queue.h"

support/Makefile.am

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ libsupport_la_SOURCES = \
5757
debug.cpp \
5858
debug.h \
5959
util.cpp \
60-
util.h
60+
util.h \
61+
\
62+
rs232wrapper.h
6163

6264
libsupport_la_LDFLAGS = -static
6365

0 commit comments

Comments
 (0)