Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > HP-UX Operating System

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-16-2008, 06:28 PM
linda
 
Posts: n/a
Default RS232 programming, helps needed...

Hi All

I am doing a project recently requires RS232 communication between a
hpux workstation and a robot. This machine has its own RS232
communication protocol which can accept commands and return result
from queries. The RS232 connection requirement is very simple.

the workstation the machine
9 pins connector 25 pins connector

Pin 2(Rx) connected to Pin 2(Tx)
Pin 3(Tx) connected to Pin 3(Rx)
Pin 5(Gnd) connected to Pin 7(Gnd)

Ive wrote a C code to control the machine. Apparently, the machine is
accepting the commands from the C program and performed its tasks, but
wouldnt response to the queries that Ive sent from the program.
Therefore Ive probe(pin2 - Tx) from the 25 pins Dsub connector and
found that the machine is actually returning the expected result but
the serial port is not set to read the result. The read result return
-1.

I am not a RS232 programmer and this is the first time I am doing so.
But I think it must something to do with the RS232 options that I
should set in my hpux box.
All kinds of RS232 related helps are appreciated. Thanks in advance.
~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-16-2008, 06:28 PM
Alex van Denzel
 
Posts: n/a
Default Re: RS232 programming, helps needed...

linda wrote:

> Hi All
>
> I am doing a project recently requires RS232 communication between a
> hpux workstation and a robot. This machine has its own RS232
> communication protocol which can accept commands and return result
> from queries. The RS232 connection requirement is very simple.
>
> the workstation the machine
> 9 pins connector 25 pins connector
>
> Pin 2(Rx) connected to Pin 2(Tx)
> Pin 3(Tx) connected to Pin 3(Rx)
> Pin 5(Gnd) connected to Pin 7(Gnd)
>
> Ive wrote a C code to control the machine. Apparently, the machine is
> accepting the commands from the C program and performed its tasks, but
> wouldnt response to the queries that Ive sent from the program.
> Therefore Ive probe(pin2 - Tx) from the 25 pins Dsub connector and
> found that the machine is actually returning the expected result but
> the serial port is not set to read the result. The read result return
> -1.
>
> I am not a RS232 programmer and this is the first time I am doing so.
> But I think it must something to do with the RS232 options that I
> should set in my hpux box.
> All kinds of RS232 related helps are appreciated. Thanks in advance.
> ~


I'd say, first try with a terminal emulation program like minicom or
kermit, or even cu to see if communication is actually happening,
assuming the robot protocol uses human-readable instructions and
responses (using "normal" ASCII).

If that works, you can debug your program, by connecting a terminal to
the serial port, after checking it's functionality with the terminal
emulator. If you don't have a terminal, but jou have a second serial
port, you can use that one. Just create a cable with two 9-pins
connectors, according to the description below.

9-pin serial null-modem cable
9-pin serial A 9-pin serial B
Pin 2 (Rx) connected to Pin 3 (Tx)
Pin 3 (Tx) connected to Pin 2 (Rx)
Pin 5 (Gnd) connected to Pin 5 (Gnd)

I'm not a RS232 programmer myself. If I need something like that I use
expect, cu, dip, minicom, kermit, or any combination of those.

So, if you post the parts of your program concerning the serial
connection, someone else might be of some help

--
Alex


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-16-2008, 06:28 PM
Stefaan A Eeckels
 
Posts: n/a
Default Re: RS232 programming, helps needed...

On 20 Sep 2004 07:24:21 -0700
plinda77@yahoo.com (linda) wrote:

> I am not a RS232 programmer and this is the first time I am doing so.
> But I think it must something to do with the RS232 options that I
> should set in my hpux box.
> All kinds of RS232 related helps are appreciated. Thanks in advance.


Start here:

http://www.stokely.com/unix.serial.p...ces/index.html

--
Stefaan
--
"What is stated clearly conceives easily." -- Inspired sales droid
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-16-2008, 06:28 PM
Wolfgang Friedrich
 
Posts: n/a
Default Re: RS232 programming, helps needed...

Hallo, linda!

We had a similar problem with RS232 connections on HP Dxxx Servers and
newer. The reason in our case was because the port on the HP Servers
required additional signals, such as "ready to receive" and so on.
The solution: plug-in two bridges in the 25-pin connector at the HP
side of the connection, one from pin 4 to 5, the other from pin 6 to 8
to 20.

I'm pretty sure that there is a HP-UX command to set the serial port
options so that it doesn't need the bridges, but we never found
that...

Hope this helps,

Wolfgang

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-16-2008, 06:28 PM
linda
 
Posts: n/a
Default Re: RS232 programming, helps needed...

> Hallo, linda!
>
> We had a similar problem with RS232 connections on HP Dxxx Servers and
> newer. The reason in our case was because the port on the HP Servers
> required additional signals, such as "ready to receive" and so on.
> The solution: plug-in two bridges in the 25-pin connector at the HP
> side of the connection, one from pin 4 to 5, the other from pin 6 to 8
> to 20.
>
> I'm pretty sure that there is a HP-UX command to set the serial port
> options so that it doesn't need the bridges, but we never found
> that...
>
> Hope this helps,
>
> Wolfgang


Hi Wolfgang

Thanks for the advise. But I'd tried these already. For my case(9 pins
connector), it is shorting pin 1,4 and 6; and shorting pin 7 and 8.
But it is still not working. I wonder why.
Can you send me the part of your code(and those settings that u have
in your code) that is reading from the serial port? I would like to
compare it with mine, if you dont mind.

thanks
linda
thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-16-2008, 06:28 PM
urle - Uli Betzler
 
Posts: n/a
Default Re: RS232 programming, helps needed...

linda <plinda77@yahoo.com> wrote:
> Thanks for the advise. But I'd tried these already. For my case(9 pins
> connector), it is shorting pin 1,4 and 6; and shorting pin 7 and 8.
> But it is still not working. I wonder why.
> Can you send me the part of your code(and those settings that u have
> in your code) that is reading from the serial port? I would like to
> compare it with mine, if you dont mind.


Did you set cread with tcsetattr?

urle

--
Uli Betzler (urle) urle@rz.uni-karlsruhe.de
Universitaet Karlsruhe, Rechenzentrum IRA/VERA/SR, Zirkel 2, 76128 Karlsruhe
phone: +49 721 608-4039 FAX: +49 721 608-9013 alternate FAX: +49 721 32550
urle = URL-Emanation = http://www.uni-karlsruhe.de/~Ulrich.Betzler/urle.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-16-2008, 06:28 PM
David Kinsell
 
Posts: n/a
Default Re: RS232 programming, helps needed...


"Wolfgang Friedrich" <news@janewolfgang.de> wrote in message news:BD76212Dyf@janewolfgang.de...
> Hallo, linda!
>
> We had a similar problem with RS232 connections on HP Dxxx Servers and
> newer. The reason in our case was because the port on the HP Servers
> required additional signals, such as "ready to receive" and so on.
> The solution: plug-in two bridges in the 25-pin connector at the HP
> side of the connection, one from pin 4 to 5, the other from pin 6 to 8
> to 20.
>
> I'm pretty sure that there is a HP-UX command to set the serial port
> options so that it doesn't need the bridges, but we never found
> that...


Turning off 'hardware handshaking' generally lets you get around problems
like that. Easy to do in minicom, I'm not familiar with how you do that in
general.

-Dave




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-16-2008, 06:28 PM
linda
 
Posts: n/a
Default Re: RS232 programming, helps needed...

Hi All,

here's my test code...

#define ENQ 5
#define ACK 6
#define NAK 15
#define STX 2
#define ETX 3

#define QUERY "XX" /* XX, something to represent an query, say 2
bytes */

int main()
{
int fd;
int io_status;
int write_status;
int close_status;
struct termio t;
char *device = "/dev/devicefile";
char query[10];
char recvbuf[10];

sprintf(query, "%c%s%c\n", STX, QUERY, ETX);
/* need to encapsulate QUERY between the STX and ETX, to be recognize
by the robot */

if((fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY))==-1)
fprintf(stderr, "Open RS232 Fail%d!\n", fd);

if((io_status = ioctl(fd, TCGETA, &t))==-1)
fprintf(stderr, "IOCTL TCGETA Fail!\n");

t.c_cflag=B9600|CS8|HUPCL|CREAD;

if((io_status = ioctl(fd, TCSETA, &t))==-1)
fprintf(stderr, "IOCTL TCSETA Fail!%d\n", io_status);

if((write_status = write(fd, &query, 5))==-1)
fprintf(stderr, "Write RS232 Fail!%d\n", write_status);

/* let say the query returns 2 bytes, YY */
/* actual data return from robot and received will be "2YY3" but ascii
character 2 and 3 is not printable(is this the problem?) therefore it
will be YY, as STX, "YY", ETX */

if((read_status = read(fd, &recvbuf, 5))==-1)
fprintf(stderr, "read RS232 Fail!%d\n", read_status);

printf("%s", recvbuf); /*returns nothing */

/* read_status received but is 0*/

close(fd);

}
/* End of code */

Is there any settings that are capable of filter away the STX and ETX
during read? or it that needed?

thanks
linda
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-16-2008, 06:28 PM
linda
 
Posts: n/a
Default Re: RS232 programming, helps needed...

Hi All

Forgot to mention...about this machine,

- utilizes a standard RS232C datalink
- incorporating a single character protocol
- interrupt mode for input
- polling and non interrupt mode for output
- uses a single character start of text(STX) and single character end of text(ETX)
to allow variable length strings to be sent as data.

- baud 9600
- start bit, 1 stop bit
- 8 bit data length
- none parity
- full duplex

thanks again
linda
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 01-16-2008, 06:28 PM
Wolfgang Friedrich
 
Posts: n/a
Default Re: RS232 programming, helps needed...

Hallo, linda!

> Thanks for the advise. But I'd tried these already. For my case(9

pins
> connector), it is shorting pin 1,4 and 6; and shorting pin 7 and 8.
> But it is still not working. I wonder why.


Ups - I haven't read your posting correctly at first, thought that the
25 pin connector is on the workstation. Yes, there are other pins to
shorten in this case, I don't know which ones, I think you are
correct with 1,4,6 and 7,8.

> Can you send me the part of your code(and those settings that u have
> in your code) that is reading from the serial port? I would like to
> compare it with mine, if you dont mind.


Sorry, there is no code that I can send to you. In most cases we
simply want to connect a serial modem for support reasons with 3 pins
(send, receive, ground). So the code in our case is the standard getty
process.
In some cases it was a communication program, which sends and receives
data to/from other machines. This program has the same problem on the
HP-UX systems. The program code is not free, and I am by no means a
programmer, so I see no chance to sent (the right) parts to you.

In any cases the connections were running without any problems after
applying the bridges in the connector. We tested this with kermit for
example.

We are using the 800 Servers, perhaps there are differences to your
700 Workstation?!

Wolfgang
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:12 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647