Added list method and modified help patch. Changed hupcl so Windows doesn't see it.
svn path=/trunk/externals/iem/comport/; revision=8802
This commit is contained in:
parent
dd2de83ed4
commit
ea14c0fe89
2 changed files with 290 additions and 220 deletions
|
|
@ -1,215 +1,222 @@
|
||||||
#N canvas 504 22 750 623 10;
|
#N canvas 458 0 800 627 10;
|
||||||
#X obj 18 436 comport 1 9600;
|
#X obj 18 436 comport 1 9600;
|
||||||
#X msg 13 189 66;
|
#X msg 13 189 66;
|
||||||
#X msg 7 147 64;
|
#X msg 7 147 64;
|
||||||
#X text 40 189 point;
|
#X text 40 189 point;
|
||||||
#X text 32 147 stream;
|
#X text 32 147 stream;
|
||||||
#X msg 18 238 86;
|
#X msg 18 238 86;
|
||||||
#X text 46 239 position;
|
#X text 46 239 position;
|
||||||
#X msg 24 283 70;
|
#X msg 24 283 70;
|
||||||
#X msg 25 323 71;
|
#X msg 25 323 71;
|
||||||
#X text 49 283 run;
|
#X text 49 283 run;
|
||||||
#X text 50 323 sleep;
|
#X text 50 323 sleep;
|
||||||
#X msg 314 51 bits 8;
|
#X msg 314 61 bits 8;
|
||||||
#X msg 314 77 stopbit 0;
|
#X msg 314 87 stopbit 0;
|
||||||
#X msg 314 103 parity 0;
|
#X msg 314 113 parity 0;
|
||||||
#X text 381 102 parity 1=even \, -1=odd \, 0=off;
|
#X text 381 112 parity 1=even \, -1=odd \, 0=off;
|
||||||
#X text 385 76 extra stopbit 1=on \, 0=off;
|
#X text 385 86 extra stopbit 1=on \, 0=off;
|
||||||
#X text 363 50 databits 5 \, 6 \, 7 \, 8;
|
#X text 363 60 databits 5 \, 6 \, 7 \, 8;
|
||||||
#X obj 56 414 r comctl;
|
#X obj 56 414 r comctl;
|
||||||
#X obj 245 438 s comctl;
|
#X obj 245 438 s comctl;
|
||||||
#X text 394 128 use handshake xon/off 1=on 0=off;
|
#X text 394 138 use handshake xon/off 1=on 0=off;
|
||||||
#X text 386 154 cts/rts hardwarehandshake 1=on 0=off;
|
#X text 386 164 cts/rts hardwarehandshake 1=on 0=off;
|
||||||
#X msg 318 214 pollintervall 1;
|
#X msg 318 214 pollintervall 1;
|
||||||
#X text 428 213 (default is 1 tick 1ms);
|
#X text 428 213 (default is 1 tick 1ms);
|
||||||
#X msg 317 246 close;
|
#X msg 317 246 close;
|
||||||
#X msg 317 272 open 1;
|
#X msg 317 272 open 1;
|
||||||
#X text 356 245 Close Serial port;
|
#X text 356 245 Close Serial port;
|
||||||
#X msg 313 415 devicename /dev/ttyS1;
|
#X msg 313 415 devicename /dev/ttyS1;
|
||||||
#X text 313 432 Danger !!! you can open every file in your system and
|
#X text 313 432 Danger !!! you can open every file in your system and
|
||||||
maybe if suid is root damage the system.;
|
maybe if suid is root damage the system.;
|
||||||
#X text 4 -9 (C) 1998-2005 IEM Winfried Ritsch GPL (see LICENSE.txt)
|
#X text 4 -9 (C) 1998-2005 IEM Winfried Ritsch GPL (see LICENSE.txt)
|
||||||
;
|
;
|
||||||
#X obj 144 50 hsl 128 15 0 255 0 0 empty empty empty -2 -6 0 8 -262144
|
#X obj 144 50 hsl 128 15 0 255 0 0 empty empty empty -2 -6 0 8 -262144
|
||||||
-1 -1 0 1;
|
-1 -1 0 1;
|
||||||
#X floatatom 183 76 5 0 0 0 - - -;
|
#X floatatom 183 76 5 0 0 0 - - -;
|
||||||
#X text 60 35 you can send bytes directly (0-255):;
|
#X text 60 35 you can send bytes directly (0-255):;
|
||||||
#X text 364 271 Open serial port by number;
|
#X text 364 271 Open serial port by number;
|
||||||
#X text 473 414 open the serial port by name;
|
#X text 449 413 open the serial port by name;
|
||||||
#X msg 362 360 dtr \$1;
|
#X msg 362 360 dtr \$1;
|
||||||
#X obj 342 360 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -250685
|
#X obj 342 360 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -250685
|
||||||
-1 0 1;
|
-1 0 1;
|
||||||
#X obj 364 380 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -1 -1 0
|
#X obj 364 380 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -1 -1 0
|
||||||
1;
|
1;
|
||||||
#X msg 384 380 rts \$1;
|
#X msg 384 380 rts \$1;
|
||||||
#X text 411 359 dtr output;
|
#X text 411 359 dtr output;
|
||||||
#X text 433 379 rts output;
|
#X text 433 379 rts output;
|
||||||
#X msg 76 361 help;
|
#X msg 61 388 help;
|
||||||
#X msg 342 339 verbose \$1;
|
#X msg 342 339 verbose \$1;
|
||||||
#X obj 323 339 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -250685
|
#X obj 323 339 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -250685
|
||||||
-1 0 1;
|
-1 0 1;
|
||||||
#X text 377 197 set poll interval for read in ms;
|
#X text 377 197 set poll interval for read in ms;
|
||||||
#X msg 123 191 info;
|
#X msg 123 191 info;
|
||||||
#X floatatom 111 499 7 0 0 1 baud - -;
|
#X floatatom 111 499 7 0 0 1 baud - -;
|
||||||
#X floatatom 214 540 4 0 0 3 parity - -;
|
#X floatatom 214 540 4 0 0 3 parity - -;
|
||||||
#X floatatom 249 540 4 0 0 2 stop - -;
|
#X floatatom 249 540 4 0 0 2 stop - -;
|
||||||
#X floatatom 283 539 4 0 0 3 data - -;
|
#X floatatom 283 539 4 0 0 3 data - -;
|
||||||
#X obj 491 502 print;
|
#X obj 491 502 print;
|
||||||
#X floatatom 387 502 4 0 0 0 port - -;
|
#X floatatom 387 502 4 0 0 0 port - -;
|
||||||
#X msg 317 298 devices;
|
#X msg 317 298 devices;
|
||||||
#X obj 141 74 % 255;
|
#X obj 141 74 % 255;
|
||||||
#X floatatom 149 95 5 0 0 0 - - -;
|
#X floatatom 149 95 5 0 0 0 - - -;
|
||||||
#X text 158 191 status list on right outlet;
|
#X text 158 191 status list on right outlet;
|
||||||
#X text 375 297 print available devices (wait for it...);
|
#X text 375 297 print available devices (wait for it...);
|
||||||
#X text 393 -9 2006 Martin Peach;
|
#X obj 69 75 key;
|
||||||
#X obj 69 75 key;
|
#X obj 69 96 sel 0;
|
||||||
#X obj 69 96 sel 0;
|
#X floatatom 58 119 5 0 0 0 ascii - -;
|
||||||
#X floatatom 58 119 5 0 0 0 ascii - -;
|
#X text 10 76 terminal:;
|
||||||
#X text 10 76 terminal:;
|
#X msg 227 272 open 0;
|
||||||
#X msg 227 272 open 0;
|
#X obj 318 505 tgl 15 0 empty empty rts/cts -10 20 1 11 -24198 -258699
|
||||||
#X obj 318 505 tgl 15 0 empty empty rts/cts -10 20 1 11 -24198 -258699
|
-1 0 1;
|
||||||
-1 0 1;
|
#X obj 352 530 tgl 15 0 empty empty xon/xoff -14 20 1 11 -24198 -258699
|
||||||
#X obj 352 530 tgl 15 0 empty empty xon/xoff -14 20 1 11 -24198 -258699
|
-1 0 1;
|
||||||
-1 0 1;
|
#X text 64 539 serial packet format:;
|
||||||
#X text 64 539 serial packet format:;
|
#X text 229 502 handshaking:;
|
||||||
#X text 229 502 handshaking:;
|
#X text 0 571 flow control inputs:;
|
||||||
#X text 0 571 flow control inputs:;
|
#X obj 145 571 tgl 15 0 empty empty dsr 0 20 1 11 -24198 -258699 -1
|
||||||
#X obj 145 571 tgl 15 0 empty empty dsr 0 20 1 11 -24198 -258699 -1
|
0 1;
|
||||||
0 1;
|
#X obj 180 571 tgl 15 0 empty empty cts 0 20 1 11 -24198 -258699 -1
|
||||||
#X obj 180 571 tgl 15 0 empty empty cts 0 20 1 11 -24198 -258699 -1
|
0 1;
|
||||||
0 1;
|
#N canvas 513 22 735 499 bauds 0;
|
||||||
#N canvas 513 22 735 499 bauds 0;
|
#X msg 229 314 baud 57600;
|
||||||
#X msg 229 314 baud 57600;
|
#X msg 229 358 baud 230400;
|
||||||
#X msg 229 358 baud 230400;
|
#X msg 229 336 baud 115200;
|
||||||
#X msg 229 336 baud 115200;
|
#X msg 222 288 baud 38400;
|
||||||
#X msg 222 288 baud 38400;
|
#X msg 229 261 baud 19200;
|
||||||
#X msg 229 261 baud 19200;
|
#X msg 229 239 baud 9600;
|
||||||
#X msg 229 239 baud 9600;
|
#X msg 229 217 baud 4800;
|
||||||
#X msg 229 217 baud 4800;
|
#X msg 229 195 baud 2400;
|
||||||
#X msg 229 195 baud 2400;
|
#X obj 162 375 s comctl;
|
||||||
#X obj 162 375 s comctl;
|
#X msg 229 173 baud 1800;
|
||||||
#X msg 229 173 baud 1800;
|
#X msg 229 151 baud 1200;
|
||||||
#X msg 229 151 baud 1200;
|
#X msg 229 129 baud 600;
|
||||||
#X msg 229 129 baud 600;
|
#X msg 229 107 baud 300;
|
||||||
#X msg 229 107 baud 300;
|
#X msg 229 85 baud 200;
|
||||||
#X msg 229 85 baud 200;
|
#X msg 229 41 baud 134;
|
||||||
#X msg 229 41 baud 134;
|
#X msg 229 19 baud 110;
|
||||||
#X msg 229 19 baud 110;
|
#X msg 229 -3 baud 75;
|
||||||
#X msg 229 -3 baud 75;
|
#X msg 229 -25 baud 50;
|
||||||
#X msg 229 -25 baud 50;
|
#X msg 229 -47 baud 0;
|
||||||
#X msg 229 -47 baud 0;
|
#X msg 229 63 baud 150;
|
||||||
#X msg 229 63 baud 150;
|
#X text 303 282 this is a special baud rate that can be configured
|
||||||
#X text 303 282 this is a special baud rate that can be configured
|
;
|
||||||
;
|
#X text 12 -48 standard baud rates for linux:;
|
||||||
#X text 12 -48 standard baud rates for linux:;
|
#X text 279 -48 0 deasserts control lines and resets the serial port
|
||||||
#X text 279 -48 0 deasserts control lines and resets the serial port
|
;
|
||||||
;
|
#X text 316 358 won't work with standard setup. See setserial;
|
||||||
#X text 316 358 won't work with standard setup. See setserial;
|
#X msg 381 227 baud \$1;
|
||||||
#X msg 381 227 baud \$1;
|
#X text 386 210 on Windows some other baud rates might work;
|
||||||
#X text 386 210 on Windows some other baud rates might work;
|
#X text 304 295 on-the-fly with setserial:;
|
||||||
#X text 304 295 on-the-fly with setserial:;
|
#X text 383 324 gives 14400 baud instead of 38400;
|
||||||
#X text 383 324 gives 14400 baud instead of 38400;
|
#X text 369 310 "setserial /dev/ttyS0 spd_cust divisor 8";
|
||||||
#X text 369 310 "setserial /dev/ttyS0 spd_cust divisor 8";
|
#X msg 381 32 115200;
|
||||||
#X msg 381 32 115200;
|
#X floatatom 395 60 7 1 115200 1 divisor - -;
|
||||||
#X floatatom 395 60 7 1 115200 1 divisor - -;
|
#X obj 381 98 / 1;
|
||||||
#X obj 381 98 / 1;
|
#X obj 395 77 sel 0;
|
||||||
#X obj 395 77 sel 0;
|
#X floatatom 381 120 7 0 0 0 - - -;
|
||||||
#X floatatom 381 120 7 0 0 0 - - -;
|
#X text 442 71 (1-115200);
|
||||||
#X text 442 71 (1-115200);
|
#X connect 0 0 8 0;
|
||||||
#X connect 0 0 8 0;
|
#X connect 1 0 8 0;
|
||||||
#X connect 1 0 8 0;
|
#X connect 2 0 8 0;
|
||||||
#X connect 2 0 8 0;
|
#X connect 3 0 8 0;
|
||||||
#X connect 3 0 8 0;
|
#X connect 4 0 8 0;
|
||||||
#X connect 4 0 8 0;
|
#X connect 5 0 8 0;
|
||||||
#X connect 5 0 8 0;
|
#X connect 6 0 8 0;
|
||||||
#X connect 6 0 8 0;
|
#X connect 7 0 8 0;
|
||||||
#X connect 7 0 8 0;
|
#X connect 9 0 8 0;
|
||||||
#X connect 9 0 8 0;
|
#X connect 10 0 8 0;
|
||||||
#X connect 10 0 8 0;
|
#X connect 11 0 8 0;
|
||||||
#X connect 11 0 8 0;
|
#X connect 12 0 8 0;
|
||||||
#X connect 12 0 8 0;
|
#X connect 13 0 8 0;
|
||||||
#X connect 13 0 8 0;
|
#X connect 14 0 8 0;
|
||||||
#X connect 14 0 8 0;
|
#X connect 15 0 8 0;
|
||||||
#X connect 15 0 8 0;
|
#X connect 16 0 8 0;
|
||||||
#X connect 16 0 8 0;
|
#X connect 17 0 8 0;
|
||||||
#X connect 17 0 8 0;
|
#X connect 18 0 8 0;
|
||||||
#X connect 18 0 8 0;
|
#X connect 19 0 8 0;
|
||||||
#X connect 19 0 8 0;
|
#X connect 24 0 8 0;
|
||||||
#X connect 24 0 8 0;
|
#X connect 29 0 31 0;
|
||||||
#X connect 29 0 31 0;
|
#X connect 30 0 32 0;
|
||||||
#X connect 30 0 32 0;
|
#X connect 31 0 33 0;
|
||||||
#X connect 31 0 33 0;
|
#X connect 32 1 31 1;
|
||||||
#X connect 32 1 31 1;
|
#X connect 33 0 24 0;
|
||||||
#X connect 33 0 24 0;
|
#X restore 622 72 pd bauds;
|
||||||
#X restore 622 72 pd bauds;
|
#X msg 314 139 xonxoff \$1;
|
||||||
#X msg 314 129 xonxoff \$1;
|
#X obj 286 140 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -250685
|
||||||
#X obj 286 130 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -250685
|
-1 0 1;
|
||||||
-1 0 1;
|
#X msg 314 165 rtscts \$1;
|
||||||
#X msg 314 155 rtscts \$1;
|
#X obj 286 167 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -250685
|
||||||
#X obj 286 157 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -250685
|
-1 0 1;
|
||||||
-1 0 1;
|
#X text 117 11 comport: a serial port interface;
|
||||||
#X text 117 11 comport: a serial port interface;
|
#X msg 102 118 13;
|
||||||
#X msg 102 118 13;
|
#X obj 421 501 tgl 15 0 empty empty open -6 20 1 11 -24198 -258699
|
||||||
#X obj 421 501 tgl 15 0 empty empty open -6 20 1 11 -24198 -258699
|
-1 0 1;
|
||||||
-1 0 1;
|
#X msg 317 320 ports;
|
||||||
#X msg 317 320 ports;
|
#X obj 111 462 route baud dsr cts parity stop data rtscts xonxoff port
|
||||||
#X obj 111 462 route baud dsr cts parity stop data rtscts xonxoff port
|
open ports;
|
||||||
open ports;
|
#X obj 456 530 print port_list;
|
||||||
#X obj 456 530 print port_list;
|
#X text 363 319 list available ports on right outlet;
|
||||||
#X text 363 319 list available ports on right outlet;
|
#X text 95 387 print usage info;
|
||||||
#X text 110 360 print usage info;
|
#X msg 59 361 48 49 50 51 52 53 54 55 56 57;
|
||||||
#X obj 289 182 tgl 15 0 empty empty empty 0 -6 0 8 -241291 -250685
|
#X text 59 344 send a list of bytes:;
|
||||||
-1 0 1;
|
#X msg 105 321 print hello_world;
|
||||||
#X msg 318 179 hupcl \$1;
|
#X text 103 304 send some text:;
|
||||||
#X text 386 179 hang-up-on-close 1=on 0=off;
|
#X text 393 -9 2006-2007 Martin Peach;
|
||||||
#X connect 0 1 78 0;
|
#X msg 515 380 hupcl \$1;
|
||||||
#X connect 1 0 0 0;
|
#X obj 515 358 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
|
||||||
#X connect 2 0 0 0;
|
1;
|
||||||
#X connect 5 0 0 0;
|
#X text 573 373 hang up connection on last close;
|
||||||
#X connect 7 0 0 0;
|
#X text 586 385 (not on Windows);
|
||||||
#X connect 8 0 0 0;
|
#X connect 0 1 77 0;
|
||||||
#X connect 11 0 18 0;
|
#X connect 1 0 0 0;
|
||||||
#X connect 12 0 18 0;
|
#X connect 2 0 0 0;
|
||||||
#X connect 13 0 18 0;
|
#X connect 5 0 0 0;
|
||||||
#X connect 17 0 0 0;
|
#X connect 7 0 0 0;
|
||||||
#X connect 21 0 18 0;
|
#X connect 8 0 0 0;
|
||||||
#X connect 23 0 18 0;
|
#X connect 11 0 18 0;
|
||||||
#X connect 24 0 18 0;
|
#X connect 12 0 18 0;
|
||||||
#X connect 26 0 18 0;
|
#X connect 13 0 18 0;
|
||||||
#X connect 29 0 30 0;
|
#X connect 17 0 0 0;
|
||||||
#X connect 29 0 52 0;
|
#X connect 21 0 18 0;
|
||||||
#X connect 34 0 18 0;
|
#X connect 23 0 18 0;
|
||||||
#X connect 35 0 34 0;
|
#X connect 24 0 18 0;
|
||||||
#X connect 36 0 37 0;
|
#X connect 26 0 18 0;
|
||||||
#X connect 37 0 18 0;
|
#X connect 29 0 30 0;
|
||||||
#X connect 40 0 0 0;
|
#X connect 29 0 52 0;
|
||||||
#X connect 41 0 18 0;
|
#X connect 34 0 18 0;
|
||||||
#X connect 42 0 41 0;
|
#X connect 35 0 34 0;
|
||||||
#X connect 44 0 0 0;
|
#X connect 36 0 37 0;
|
||||||
#X connect 51 0 18 0;
|
#X connect 37 0 18 0;
|
||||||
#X connect 52 0 0 0;
|
#X connect 40 0 0 0;
|
||||||
#X connect 52 0 53 0;
|
#X connect 41 0 18 0;
|
||||||
#X connect 57 0 58 0;
|
#X connect 42 0 41 0;
|
||||||
#X connect 58 1 59 0;
|
#X connect 44 0 0 0;
|
||||||
#X connect 58 1 0 0;
|
#X connect 51 0 18 0;
|
||||||
#X connect 61 0 18 0;
|
#X connect 52 0 0 0;
|
||||||
#X connect 70 0 18 0;
|
#X connect 52 0 53 0;
|
||||||
#X connect 71 0 70 0;
|
#X connect 56 0 57 0;
|
||||||
#X connect 72 0 18 0;
|
#X connect 57 1 58 0;
|
||||||
#X connect 73 0 72 0;
|
#X connect 57 1 0 0;
|
||||||
#X connect 75 0 0 0;
|
#X connect 60 0 18 0;
|
||||||
#X connect 77 0 18 0;
|
#X connect 69 0 18 0;
|
||||||
#X connect 78 0 45 0;
|
#X connect 70 0 69 0;
|
||||||
#X connect 78 1 67 0;
|
#X connect 71 0 18 0;
|
||||||
#X connect 78 2 68 0;
|
#X connect 72 0 71 0;
|
||||||
#X connect 78 3 46 0;
|
#X connect 74 0 0 0;
|
||||||
#X connect 78 4 47 0;
|
#X connect 76 0 18 0;
|
||||||
#X connect 78 5 48 0;
|
#X connect 77 0 45 0;
|
||||||
#X connect 78 6 62 0;
|
#X connect 77 1 66 0;
|
||||||
#X connect 78 7 63 0;
|
#X connect 77 2 67 0;
|
||||||
#X connect 78 8 50 0;
|
#X connect 77 3 46 0;
|
||||||
#X connect 78 9 76 0;
|
#X connect 77 4 47 0;
|
||||||
#X connect 78 10 79 0;
|
#X connect 77 5 48 0;
|
||||||
#X connect 78 11 49 0;
|
#X connect 77 6 61 0;
|
||||||
#X connect 82 0 83 0;
|
#X connect 77 7 62 0;
|
||||||
#X connect 83 0 18 0;
|
#X connect 77 8 50 0;
|
||||||
|
#X connect 77 9 75 0;
|
||||||
|
#X connect 77 10 78 0;
|
||||||
|
#X connect 77 11 49 0;
|
||||||
|
#X connect 81 0 0 0;
|
||||||
|
#X connect 83 0 0 0;
|
||||||
|
#X connect 86 0 18 0;
|
||||||
|
#X connect 87 0 86 0;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ MP 20060924 added comport_enum to list available ports in Windows
|
||||||
MP 20060925 add devices message to enumerate actual devices, info just outputs current port state
|
MP 20060925 add devices message to enumerate actual devices, info just outputs current port state
|
||||||
MP 20061016 write_serial checks for GetOverlappedResult to avoid tx buffer overflow errors
|
MP 20061016 write_serial checks for GetOverlappedResult to avoid tx buffer overflow errors
|
||||||
MP 20070719 added "ports" method to output list of available ports on status outlet
|
MP 20070719 added "ports" method to output list of available ports on status outlet
|
||||||
|
MP 20071011 added comport_list and write_serials for list processing based on code by Thomas O Fredericks <tof@danslchamp.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "m_pd.h"
|
#include "m_pd.h"
|
||||||
|
|
@ -95,6 +96,7 @@ typedef struct comport
|
||||||
|
|
||||||
#define COMPORT_MAX 99
|
#define COMPORT_MAX 99
|
||||||
#define USE_DEVICENAME 9999 /* use the device name instead of the number */
|
#define USE_DEVICENAME 9999 /* use the device name instead of the number */
|
||||||
|
#define MAX_LIST 1000 /* arbitrary maximum list length for comport_list */
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* we don't use the table for windos cos we can set the number directly. */
|
/* we don't use the table for windos cos we can set the number directly. */
|
||||||
|
|
@ -229,15 +231,16 @@ static int set_ctsrts(t_comport *x, int nr);
|
||||||
static int set_dtr(t_comport *x, int nr);
|
static int set_dtr(t_comport *x, int nr);
|
||||||
static int set_rts(t_comport *x, int nr);
|
static int set_rts(t_comport *x, int nr);
|
||||||
static int set_xonxoff(t_comport *x, int nr);
|
static int set_xonxoff(t_comport *x, int nr);
|
||||||
static int set_hupcl(t_comport *x, int nr);
|
|
||||||
static int set_serial(t_comport *x);
|
static int set_serial(t_comport *x);
|
||||||
static int write_serial(t_comport *x, unsigned char serial_byte);
|
static int write_serial(t_comport *x, unsigned char serial_byte);
|
||||||
|
static int write_serials(t_comport *x, unsigned char *serial_buf, size_t buf_length);
|
||||||
static int comport_get_dsr(t_comport *x);
|
static int comport_get_dsr(t_comport *x);
|
||||||
static int comport_get_cts(t_comport *x);
|
static int comport_get_cts(t_comport *x);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static HANDLE open_serial(unsigned int com_num, t_comport *x);
|
static HANDLE open_serial(unsigned int com_num, t_comport *x);
|
||||||
static HANDLE close_serial(t_comport *x);
|
static HANDLE close_serial(t_comport *x);
|
||||||
#else
|
#else
|
||||||
|
static int set_hupcl(t_comport *x, int nr);
|
||||||
static int open_serial(unsigned int com_num, t_comport *x);
|
static int open_serial(unsigned int com_num, t_comport *x);
|
||||||
static int close_serial(t_comport *x);
|
static int close_serial(t_comport *x);
|
||||||
static long get_baud_ratebits(t_float *baud);
|
static long get_baud_ratebits(t_float *baud);
|
||||||
|
|
@ -245,6 +248,7 @@ static long get_baud_ratebits(t_float *baud);
|
||||||
static void comport_pollintervall(t_comport *x, t_floatarg g);
|
static void comport_pollintervall(t_comport *x, t_floatarg g);
|
||||||
static void comport_tick(t_comport *x);
|
static void comport_tick(t_comport *x);
|
||||||
static void comport_float(t_comport *x, t_float f);
|
static void comport_float(t_comport *x, t_float f);
|
||||||
|
static void comport_list(t_comport *x, t_symbol *s, int argc, t_atom *argv);
|
||||||
static void *comport_new(t_floatarg com_num, t_floatarg fbaud);
|
static void *comport_new(t_floatarg com_num, t_floatarg fbaud);
|
||||||
static void comport_free(t_comport *x);
|
static void comport_free(t_comport *x);
|
||||||
static void comport_baud(t_comport *x,t_floatarg f);
|
static void comport_baud(t_comport *x,t_floatarg f);
|
||||||
|
|
@ -617,6 +621,39 @@ static int write_serial(t_comport *x, unsigned char serial_byte)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int write_serials(t_comport *x, unsigned char *serial_buf, size_t buf_length)
|
||||||
|
{
|
||||||
|
OVERLAPPED osWrite = {0};
|
||||||
|
DWORD dwWritten;
|
||||||
|
DWORD dwToWrite = (DWORD)buf_length;
|
||||||
|
DWORD dwErr;
|
||||||
|
DWORD numTransferred = 0L;
|
||||||
|
|
||||||
|
osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
if (osWrite.hEvent == NULL)
|
||||||
|
{
|
||||||
|
post("Couldn't create event. Transmission aborted.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!WriteFile(x->comhandle, serial_buf, dwToWrite, &dwWritten, &osWrite))
|
||||||
|
{
|
||||||
|
dwErr = GetLastError();
|
||||||
|
if (dwErr != ERROR_IO_PENDING)
|
||||||
|
{
|
||||||
|
post("WriteFile error: %d", (int)dwErr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!GetOverlappedResult(x->comhandle, &osWrite, &numTransferred, TRUE))
|
||||||
|
{/* wait for the character(s) to be sent */
|
||||||
|
dwErr = GetLastError();
|
||||||
|
post("WriteFile:GetOverlappedResult error: %d", (int)dwErr);
|
||||||
|
}
|
||||||
|
CloseHandle(osWrite.hEvent);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int comport_get_dsr(t_comport *x)
|
static int comport_get_dsr(t_comport *x)
|
||||||
{
|
{
|
||||||
short dsr_state = 0;
|
short dsr_state = 0;
|
||||||
|
|
@ -974,6 +1011,14 @@ static int write_serial(t_comport *x, unsigned char serial_byte)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int write_serials(t_comport *x, unsigned char *serial_buf, size_t buf_length)
|
||||||
|
{
|
||||||
|
int result = write(x->comhandle,(char *)serial_buf, buf_length);
|
||||||
|
if (result != buf_length)
|
||||||
|
post ("[comport] write returned %d, errno is %d", result, errno);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static int comport_get_dsr(t_comport *x)
|
static int comport_get_dsr(t_comport *x)
|
||||||
{
|
{
|
||||||
short dsr_state = 0;
|
short dsr_state = 0;
|
||||||
|
|
@ -1091,6 +1136,25 @@ static void comport_float(t_comport *x, t_float f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void comport_list(t_comport *x, t_symbol *s, int argc, t_atom *argv)
|
||||||
|
{
|
||||||
|
unsigned char temp_array[MAX_LIST];/* arbitrary maximum list length */
|
||||||
|
int i, count;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
count = argc;
|
||||||
|
if (argc > MAX_LIST)
|
||||||
|
{
|
||||||
|
post ("[comport] truncated list of %d elements to %d", argc, count);
|
||||||
|
count = MAX_LIST;
|
||||||
|
}
|
||||||
|
for(i = 0; i < count; i++)
|
||||||
|
temp_array[i] = ((unsigned char)atom_getint(argv+i))&0xFF; /* brutal conv */
|
||||||
|
result = write_serials(x, temp_array, count);
|
||||||
|
if (result < 0)
|
||||||
|
post ("[comport] write returned %d, errno is %d", result, errno);
|
||||||
|
}
|
||||||
|
|
||||||
static void *comport_new(t_floatarg com_num, t_floatarg fbaud)
|
static void *comport_new(t_floatarg com_num, t_floatarg fbaud)
|
||||||
{
|
{
|
||||||
t_comport test;
|
t_comport test;
|
||||||
|
|
@ -1403,10 +1467,9 @@ static void comport_xonxoff(t_comport *x,t_floatarg f)
|
||||||
|
|
||||||
static void comport_hupcl(t_comport *x,t_floatarg f)
|
static void comport_hupcl(t_comport *x,t_floatarg f)
|
||||||
{
|
{
|
||||||
//#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
//#else
|
|
||||||
set_hupcl(x,f);
|
set_hupcl(x,f);
|
||||||
//#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void comport_close(t_comport *x)
|
static void comport_close(t_comport *x)
|
||||||
|
|
@ -1737,7 +1800,7 @@ void comport_setup(void)
|
||||||
0, A_DEFFLOAT, A_DEFFLOAT, 0);
|
0, A_DEFFLOAT, A_DEFFLOAT, 0);
|
||||||
|
|
||||||
class_addfloat(comport_class, (t_method)comport_float);
|
class_addfloat(comport_class, (t_method)comport_float);
|
||||||
|
class_addlist(comport_class, (t_method)comport_list);
|
||||||
/*
|
/*
|
||||||
class_addbang(comport_class, comport_bang
|
class_addbang(comport_class, comport_bang
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue