Socat hangs when piping stdin to tcp server - tcp

I have an embedded linux system running a tcp server.
Telnet can connect to and use the tcp server interactively just fine.
I am trying to use socat to make the same connection, by linking stdin to the tcp server, like so:
socat - tcp:localhost:8088
I get the initial response from the server, and I can type, but as soon as I press enter, the terminal hangs (I can get out of this with Ctrl + C as long as I am not using the raw socat option.)
If I do the same thing but with readline, everything mostly works as expected:
socat readline tcp:localhost:8088
However, with readline, the terminal echoes my input, and then the response from the server also echoes it. This is more than just an annoyance, since things like passwords (which should not even be echoed once) are now visible.
Ideally, I would just use stdin instead of readline, so that I could send each character as soon as I type it, and turn off stdin echo. That way, when I type a character, the tcp server receives it and echoes it immediately, but only if it is supposed to.
But socat is hanging with the stdin option for reasons I don't understand.
I'm looking for an explanation as to why stdin is locking up the thread, or a workaround possibly using readline or similar.
EDIT: Here is the dddd debug output from the socat command when I use stdin:
sh-5.0# socat -d -d -d -d -lu - tcp:localhost:8088
2022/02/04 01:34:58.805536 socat[1074] D getpid()
2022/02/04 01:34:58.807631 socat[1074] D getpid() -> 1074
2022/02/04 01:34:58.807667 socat[1074] D setenv("SOCAT_PID", "1074",
1)
2022/02/04 01:34:58.807687 socat[1074] D setenv() -> 0
2022/02/04 01:34:58.807704 socat[1074] D setenv("SOCAT_PPID", "1074",
1)
2022/02/04 01:34:58.807724 socat[1074] D setenv() -> 0
2022/02/04 01:34:58.807737 socat[1074] I socat by Gerhard Rieger and
contributors - see www.dest-unreach.org
2022/02/04 01:34:58.807752 socat[1074] I This product includes
software developed by the OpenSSL Project for use in the OpenSSL
Toolkit. (http://www.openssl.org/)
2022/02/04 01:34:58.807767 socat[1074] I This product includes
software written by Tim Hudson (tjh#cryptsoft.com)
2022/02/04 01:34:58.807781 socat[1074] D socat version 1.7.3.3 on May
25 2021 13:47:29
2022/02/04 01:34:58.807795 socat[1074] D setenv("SOCAT_VERSION",
"1.7.3.3", 1)
2022/02/04 01:34:58.807811 socat[1074] D setenv() -> 0
2022/02/04 01:34:58.807827 socat[1074] D running on Linux version #1
SMP Mon Jan 31 20:48:32 UTC 2022, release 5.4.0, machine aarch64
2022/02/04 01:34:58.807845 socat[1074] D argv[0]: "socat"
2022/02/04 01:34:58.807857 socat[1074] D argv[1]: "-d"
2022/02/04 01:34:58.807870 socat[1074] D argv[2]: "-d"
2022/02/04 01:34:58.807883 socat[1074] D argv[3]: "-d"
2022/02/04 01:34:58.807895 socat[1074] D argv[4]: "-d"
2022/02/04 01:34:58.807907 socat[1074] D argv[5]: "-lu"
2022/02/04 01:34:58.807920 socat[1074] D argv[6]: "-"
2022/02/04 01:34:58.807932 socat[1074] D argv[7]: "tcp:localhost:8088"
2022/02/04 01:34:58.807945 socat[1074] D sigaction(1, 0xffffc8d63a18,
0x0)
2022/02/04 01:34:58.807960 socat[1074] D sigaction() -> 0
2022/02/04 01:34:58.807973 socat[1074] D sigaction(2, 0xffffc8d63a18,
0x0)
2022/02/04 01:34:58.807987 socat[1074] D sigaction() -> 0
2022/02/04 01:34:58.808000 socat[1074] D sigaction(3, 0xffffc8d63a18,
0x0)
2022/02/04 01:34:58.808014 socat[1074] D sigaction() -> 0
2022/02/04 01:34:58.808026 socat[1074] D sigaction(4, 0xffffc8d63a18,
0x0)
2022/02/04 01:34:58.808040 socat[1074] D sigaction() -> 0
2022/02/04 01:34:58.808053 socat[1074] D sigaction(6, 0xffffc8d63a18,
0x0)
2022/02/04 01:34:58.808067 socat[1074] D sigaction() -> 0
2022/02/04 01:34:58.808079 socat[1074] D sigaction(7, 0xffffc8d63a18,
0x0)
2022/02/04 01:34:58.808092 socat[1074] D sigaction() -> 0
2022/02/04 01:34:58.808105 socat[1074] D sigaction(8, 0xffffc8d63a18,
0x0)
2022/02/04 01:34:58.808119 socat[1074] D sigaction() -> 0
2022/02/04 01:34:58.808132 socat[1074] D sigaction(11, 0xffffc8d63a18,
0x0)
2022/02/04 01:34:58.808146 socat[1074] D sigaction() -> 0
2022/02/04 01:34:58.808158 socat[1074] D sigaction(15, 0xffffc8d63a18,
0x0)
2022/02/04 01:34:58.808172 socat[1074] D sigaction() -> 0
2022/02/04 01:34:58.808185 socat[1074] D signal(13, 0x1)
2022/02/04 01:34:58.808200 socat[1074] D signal() -> 0x0
2022/02/04 01:34:58.808213 socat[1074] D atexit(0xaaaaba73c4a0)
2022/02/04 01:34:58.808226 socat[1074] D atexit() -> 0
2022/02/04 01:34:58.808267 socat[1074] D calloc(1, 848)
2022/02/04 01:34:58.808284 socat[1074] D calloc() -> 0xaaaadd2cc680
2022/02/04 01:34:58.808304 socat[1074] D malloc(1024)
2022/02/04 01:34:58.808318 socat[1074] D malloc() -> 0xaaaadd2cca00
2022/02/04 01:34:58.808333 socat[1074] D calloc(1, 848)
2022/02/04 01:34:58.808350 socat[1074] D calloc() -> 0xaaaadd2cce10
2022/02/04 01:34:58.808364 socat[1074] D calloc(1, 848)
2022/02/04 01:34:58.808377 socat[1074] D calloc() -> 0xaaaadd2cd170
2022/02/04 01:34:58.808391 socat[1074] D isatty(0)
2022/02/04 01:34:58.808411 socat[1074] D isatty() -> 1
2022/02/04 01:34:58.808424 socat[1074] D tcgetattr(0, 0xaaaadd2ccf6c)
2022/02/04 01:34:58.808461 socat[1074] D tcgetattr(,
{00005400,00000005,00001cb2,0000083b, 4098,4098,
03,1c,7f,15,04,00,01,00,11,13,1a,00,12,0f,17,16,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00})
-> 0
2022/02/04 01:34:58.808480 socat[1074] D isatty(1)
2022/02/04 01:34:58.808494 socat[1074] D isatty() -> 1
2022/02/04 01:34:58.808507 socat[1074] D tcgetattr(1, 0xaaaadd2cd2cc)
2022/02/04 01:34:58.808542 socat[1074] D tcgetattr(,
{00005400,00000005,00001cb2,0000083b, 4098,4098,
03,1c,7f,15,04,00,01,00,11,13,1a,00,12,0f,17,16,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00})
-> 0
2022/02/04 01:34:59.141868 socat[1074] D malloc(128)
2022/02/04 01:34:59.141888 socat[1074] D malloc() -> 0xaaaadd2cd4d0
2022/02/04 01:34:59.141903 socat[1074] D malloc(128)
2022/02/04 01:34:59.141916 socat[1074] D malloc() -> 0xaaaadd2cd560
2022/02/04 01:34:59.141931 socat[1074] N reading from and writing to
stdio
2022/02/04 01:34:59.141946 socat[1074] D calloc(1, 848)
2022/02/04 01:34:59.141959 socat[1074] D calloc() -> 0xaaaadd2cd5f0
2022/02/04 01:34:59.141983 socat[1074] D malloc(1024)
2022/02/04 01:34:59.141997 socat[1074] D malloc() -> 0xaaaadd2cd9b0
2022/02/04 01:34:59.142015 socat[1074] D getaddrinfo("localhost",
NULL, {1,0,1,6,0,0x0,0x0,0x0}, 0xffffc8d63538)
2022/02/04 01:34:59.142789 socat[1074] D getaddrinfo(,,,{{AF=10
[0000:0000:0000:0000:0000:0000:0000:0001]:0, }) -> 0
2022/02/04 01:34:59.142815 socat[1074] D malloc(128)
2022/02/04 01:34:59.142830 socat[1074] D malloc() -> 0xaaaadd2ce610
2022/02/04 01:34:59.142847 socat[1074] N opening connection to AF=2
127.0.0.1:8088
2022/02/04 01:34:59.142861 socat[1074] I starting connect loop
2022/02/04 01:34:59.142876 socat[1074] D socket(2, 1, 6)
2022/02/04 01:34:59.142900 socat[1074] I socket(2, 1, 6) -> 5
2022/02/04 01:34:59.142919 socat[1074] D fcntl(5, 2, 1)
2022/02/04 01:34:59.142935 socat[1074] D fcntl() -> 0
2022/02/04 01:34:59.142954 socat[1074] D connect(5, {2,AF=2
127.0.0.1:8088}, 16)
2022/02/04 01:34:59.145199 socat[1074] D connect() -> 0
2022/02/04 01:34:59.145246 socat[1074] D getsockname(5,
0xffffc8d635b8, 0xffffc8d6359c{112})
2022/02/04 01:34:59.145269 socat[1074] D getsockname(, {AF=2
127.0.0.1:46294}, {16}) -> 0
2022/02/04 01:34:59.145286 socat[1074] N successfully connected from
local address AF=2 127.0.0.1:46294
2022/02/04 01:34:59.145306 socat[1074] I resolved and opened all sock
addresses
2022/02/04 01:34:59.145321 socat[1074] D malloc(16385)
2022/02/04 01:34:59.145344 socat[1074] D malloc() -> 0xaaaadd2cf400
2022/02/04 01:34:59.145360 socat[1074] N starting data transfer loop
with FDs [0,1] and [5,5]
2022/02/04 01:34:59.145375 socat[1074] D data loop: sock1->eof=0,
sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2022/02/04 01:34:59.145395 socat[1074] D select(6, &0x21, &0x22, &0x0,
NULL/0.000000)
2022/02/04 01:34:59.145426 socat[1074] D select -> (, 0x0, 0x20, 0x0,
NULL/0.000000), 1
2022/02/04 01:34:59.145443 socat[1074] D data loop: sock1->eof=0,
sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2022/02/04 01:34:59.145461 socat[1074] D select(6, &0x21, &0x2, &0x0,
NULL/0.000000)
2022/02/04 01:34:59.157132 socat[1074] D select -> (, 0x20, 0x0, 0x0,
NULL/0.000000), 1
2022/02/04 01:34:59.157178 socat[1074] D data loop: sock1->eof=0,
sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2022/02/04 01:34:59.157198 socat[1074] D select(2, &0x1, &0x2, &0x0,
NULL/0.000000)
2022/02/04 01:34:59.401692 socat[1074] D select -> (, 0x0, 0x2, 0x0,
NULL/0.000000), 1
2022/02/04 01:34:59.401732 socat[1074] D read(5, 0xaaaadd2cf400, 8192)
2022/02/04 01:34:59.401765 socat[1074] D read -> 48
2022/02/04 01:34:59.401782 socat[1074] D write(1, 0xaaaadd2cf400, 48)
ÿûÿû
Connect to IP address 169.254.12.16
2022/02/04 01:34:59.401809 socat[1074] D write -> 48
2022/02/04 01:34:59.401823 socat[1074] I transferred 48 bytes from 5
to 1
2022/02/04 01:34:59.401838 socat[1074] D data loop: sock1->eof=0,
sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2022/02/04 01:34:59.401856 socat[1074] D select(6, &0x21, &0x2, &0x0,
NULL/0.000000)
2022/02/04 01:34:59.462969 socat[1074] D select -> (, 0x0, 0x2, 0x0,
NULL/0.000000), 1
2022/02/04 01:34:59.463017 socat[1074] D data loop: sock1->eof=0,
sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2022/02/04 01:34:59.463036 socat[1074] D select(6, &0x21, &0x0, &0x0,
NULL/0.000000)
At this point, I can still type, but no matter what I do, I get nothing in response.

Probably it is not Socat that hangs but the server. Use options -v -x to see what data Socat transfers in both situations and compare; maybe there are different line termination characters involved.

Turns out it was a combination of things.
The version of socat I was using (1.7.3.3) has a bug when using certain options. See https://bugs.launchpad.net/ubuntu/+source/socat/+bug/1883957 for more info.
The tty options in my terminal were atypical somehow. By using "stty sane", and then adding -brkint, I got the entire thing working with stdin.
My final solution uses socat version 1.7.4.3, and looks like this:
stty sane
stty -brkint -icanon && socat -,echo=0 tcp:localhost:8088

Related

Pipeline Diagram of IO2I Microarchitecture

Is my pipeline correct for the given sequence of instructions? If it is not, can you shine some light on where I went wrong? EDIT: I forgot to add the issue stage of the mul instruction.
MUL R6, R7, R8
ADD R9, R10, R11
ADD R11, R12, R13
ADD R13, R14, R15
ADD R19, R13, R10
LW R2, R3
ADD R12, R16, R19
LW R5, R2
ADD R15, R20, R21
MUL IF ID I Y0 Y1 Y2 Y3 Y4 W C
ADD IF ID I X0 W r C
ADD IF ID I X0 W r C
ADD IF ID I X0 W r C
ADD IF ID I I X0 W r C
LW IF ID ID I L0 L1 W r C
ADD IF IF ID I I X0 W r C
LW IF ID ID I L0 L1 W r C
ADD IF IF ID I I X0 W r C

How to code Keil-c51 and Simplicity Studio for c8051f340?

I'm going to build the following code for c8051f340 using keil-c51 or Simplicity Studio. How should I modify it to make it work?
The code itself cannot work when flashed.
ORG 0
MOV A, #0
MOV P2, #0
LOOP:
INC P2
CALL Delay
SJMP LOOP
Delay:
MOV R2, #3
MOV R1, #0
MOV R2, #0
DLP:
DJNZ R0, DLP
DJNZ R1, DLP
DJNZ R2, DLP
RET

How do I set up the speaker on a HCS12 microcontroller?

Basically, my microcontroller is supposed to play a sound based on the push buttons (PTH) I press and light up the LED (PORTB). What I am stuck on is how to set up the speaker to output sound when the push buttons are pressed. A lot of the code is based off code from here: http://www.microdigitaled.com/HCS12/Hardware/Dragon12-Plus-Support.htm
Specifically the link about the buzzer. Also when I use the code provided I am able to hear sound coming from my microcontroller; however not when I try to include the push button into the code.
I would greatly appreciate any hints, comments, tips, or suggestions. Thank you so much!
Here is my code so far:
;----------------------USE $1000-$2FFF for Scratch Pad
R1 EQU $1001
R2 EQU $1002
R3 EQU $1003
R4 EQU $1004
;code section
ORG $2000 ;Flash ROM address for Dragon12+
Entry:
LDS #$2000 ;Stack
BSET DDRT,%00100000 ;PTT5 as Output pin for buzzer
BSET DDRP,#$0F ; Set Port P pins 0-3 to output
BSET PTP, #$0F ; Disable 7-Segment Display
; LED
BSET DDRB,$FF
BSET DDRJ,$02
BCLR PTJ,$02
; PBs
BCLR DDRH,$0F
BCLR PTH,$FF ;PORTB as Output
;-------Sound the Buzzer at PTT5
BACK
;-------Get data from DIP switches connected to PORTH and send it to LEDs of PORTB
;how is the speaker supposed to be set up? because when I try the code the speaker does not output any sound.
LDAA PTH ;Get data from DIP Switches of PTH
STAA PORTB ;and send it to PORTB
BSET PTT,%00100000 ;PTT5=1
JSR DELAY
BCLR PTT,%00100000 ;PTT5=0
JSR DELAY
BRA BACK ;Keep toggling buzzer
Is my delay okay? Am I on the right track or is there a more convenient way of changing the notes?
;----------DELAY
DELAY
COMA
TSTA
CMPA #$01
BNE no_note1
PSHA ;Save Reg A on Stack
LDAA #7 ;Change this value to hear
STAA R3 ;different Buzzer sounds
;--1 msec delay. The Serial Monitor works at speed of 48MHz with XTAL=8MHz on Dragon12+ board
;Freq. for Instruction Clock Cycle is 24MHz (1/2 of 48Mhz).
;(1/24MHz) x 10 Clk x240x10=1 msec. Overheads are excluded in this calculation.
L3 LDAA #10
STAA R2
L2 LDAA #200
STAA R1
L1 NOP ;1 Intruction Clk Cycle
NOP ;1
NOP ;1
DEC R1 ;4
BNE L1 ;3
DEC R2 ;Total Instr.Clk=10
BNE L2
DEC R3
BNE L3
PULA ;Restore Reg A
no_note1:
CMPA #$02
BNE no_note2
PSHA ;Save Reg A on Stack
LDAA #3 ;Change this value to hear
STAA R3 ;different Buzzer sounds
;--1 msec delay. The Serial Monitor works at speed of 48MHz with XTAL=8MHz on Dragon12+ board
;Freq. for Instruction Clock Cycle is 24MHz (1/2 of 48Mhz).
;(1/24MHz) x 10 Clk x240x10=1 msec. Overheads are excluded in this calculation.
L9 LDAA #10
STAA R2
L8 LDAA #210
STAA R1
L7 NOP ;1 Intruction Clk Cycle
NOP ;1
NOP ;1
DEC R1 ;4
BNE L7 ;3
DEC R2 ;Total Instr.Clk=10
BNE L8
DEC R3
BNE L9
PULA ;Restore Reg A
no_note2:
CMPA #$04
BNE no_note3
PSHA ;Save Reg A on Stack
LDAA #2 ;Change this value to hear
STAA R3 ;different Buzzer sounds
;--1 msec delay. The Serial Monitor works at speed of 48MHz with XTAL=8MHz on Dragon12+ board
;Freq. for Instruction Clock Cycle is 24MHz (1/2 of 48Mhz).
;(1/24MHz) x 10 Clk x240x10=1 msec. Overheads are excluded in this calculation.
L4 LDAA #15
STAA R2
L5 LDAA #240
STAA R1
L6 NOP ;1 Intruction Clk Cycle
NOP ;1
NOP ;1
DEC R1 ;4
BNE L6 ;3
DEC R2 ;Total Instr.Clk=10
BNE L5
DEC R3
BNE L4
PULA ;Restore Reg A
no_note3:
CMPA #$08
BNE no_note4
PSHA ;Save Reg A on Stack
LDAA #9 ;Change this value to hear
STAA R3 ;different Buzzer sounds
;--1 msec delay. The Serial Monitor works at speed of 48MHz with XTAL=8MHz on Dragon12+ board
;Freq. for Instruction Clock Cycle is 24MHz (1/2 of 48Mhz).
;(1/24MHz) x 10 Clk x240x10=1 msec. Overheads are excluded in this calculation.
L30 LDAA #16
STAA R2
L20 LDAA #249
STAA R1
L10 NOP ;1 Intruction Clk Cycle
NOP ;1
NOP ;1
DEC R1 ;4
BNE L10 ;3
DEC R2 ;Total Instr.Clk=10
BNE L20
DEC R3
BNE L30
;--------------
PULA ;Restore Reg A
no_note4:
RTS
;-------------------
;----------------------------------------------------
; Interrupt Vector
;----------------------------------------------------
; Port H Vector
; $3E4C = $FFCC - $C180
ORG $3E4C
FDB DELAY
FINISH:
NOP
END

Control layout using graphviz twopi

I am trying to draw a graph showing search prefixes using twopi. I have a simple input file and am getting this output:
alt text http://www.freeimagehosting.net/uploads/th.ac6cd51528.png
(full image)
Here is the input file:
digraph search {
// ordering=out;
// color=blue;
// rank=same;
// overlap=scale;
rankdir=LR;
root=root;
ranksep=1.25;
overlap=true;
"root";
a [color=none,fontsize=12];
b [color=none,fontsize=12];
c [color=none,fontsize=12];
d [color=none,fontsize=12];
e [color=none,fontsize=12];
f [color=none,fontsize=12];
#g [color=none,fontsize=12];
h [color=none,fontsize=12];
i [color=none,fontsize=12];
j [color=none,fontsize=12];
k [color=none,fontsize=12];
l [color=none,fontsize=12];
m [color=none,fontsize=12];
n [color=none,fontsize=12];
o [color=none,fontsize=12];
p [color=none,fontsize=12];
q [color=none,fontsize=12];
r [color=none,fontsize=12];
s [color=none,fontsize=12];
t [color=none,fontsize=12];
u [color=none,fontsize=12];
v [color=none,fontsize=12];
w [color=none,fontsize=12];
x [color=none,fontsize=12];
y [color=none,fontsize=12];
#ga [color=none,fontsize=12];
gb [color=none,fontsize=12];
gc [color=none,fontsize=12];
gd [color=none,fontsize=12];
ge [color=none,fontsize=12];
gf [color=none,fontsize=12];
gg [color=none,fontsize=12];
gh [color=none,fontsize=12];
gi [color=none,fontsize=12];
gj [color=none,fontsize=12];
gk [color=none,fontsize=12];
gl [color=none,fontsize=12];
gm [color=none,fontsize=12];
gn [color=none,fontsize=12];
go [color=none,fontsize=12];
gp [color=none,fontsize=12];
gq [color=none,fontsize=12];
gr [color=none,fontsize=12];
gs [color=none,fontsize=12];
gt [color=none,fontsize=12];
gu [color=none,fontsize=12];
gv [color=none,fontsize=12];
gw [color=none,fontsize=12];
gx [color=none,fontsize=12];
gy [color=none,fontsize=12];
gaa [color=none,fontsize=12];
gab [color=none,fontsize=12];
gac [color=none,fontsize=12];
gad [color=none,fontsize=12];
gae [color=none,fontsize=12];
gaf [color=none,fontsize=12];
gag [color=none,fontsize=12];
gah [color=none,fontsize=12];
gai [color=none,fontsize=12];
gaj [color=none,fontsize=12];
gak [color=none,fontsize=12];
gal [color=none,fontsize=12];
gam [color=none,fontsize=12];
gan [color=none,fontsize=12];
gao [color=none,fontsize=12];
gap [color=none,fontsize=12];
gaq [color=none,fontsize=12];
#gaz [color=none,fontsize=12];
gas [color=none,fontsize=12];
gat [color=none,fontsize=12];
gau [color=none,fontsize=12];
gav [color=none,fontsize=12];
gaw [color=none,fontsize=12];
gax [color=none,fontsize=12];
gay [color=none,fontsize=12];
gaza [color=none,fontsize=12];
gazb [color=none,fontsize=12];
gazc [color=none,fontsize=12];
gazd [color=none,fontsize=12];
gaze [color=none,fontsize=12];
#gazf [color=none,fontsize=12];
gazg [color=none,fontsize=12];
gazh [color=none,fontsize=12];
gazi [color=none,fontsize=12];
gazj [color=none,fontsize=12];
gazk [color=none,fontsize=12];
gazl [color=none,fontsize=12];
gazm [color=none,fontsize=12];
gazn [color=none,fontsize=12];
gazo [color=none,fontsize=12];
gazp [color=none,fontsize=12];
gazq [color=none,fontsize=12];
gazr [color=none,fontsize=12];
gazs [color=none,fontsize=12];
gazt [color=none,fontsize=12];
gazu [color=none,fontsize=12];
gazv [color=none,fontsize=12];
gazw [color=none,fontsize=12];
gazx [color=none,fontsize=12];
gazy [color=none,fontsize=12];
root -> a [minlen=2];
root -> b [minlen=2];
root -> c [minlen=2];
root -> d [minlen=2];
root -> e [minlen=2];
root -> f [minlen=2];
root -> g [minlen=2];
root -> h [minlen=2];
root -> i [minlen=2];
root -> j [minlen=2];
root -> k [minlen=2];
root -> l [minlen=2];
root -> m [minlen=2];
root -> n [minlen=2];
root -> o [minlen=2];
root -> p [minlen=2];
root -> q [minlen=2];
root -> r [minlen=2];
root -> s [minlen=20];
root -> t [minlen=2];
root -> u [minlen=2];
root -> v [minlen=2];
root -> w [minlen=2];
root -> x [minlen=2];
root -> y [minlen=2];
root -> 0 [minlen=2];
root -> 1 [minlen=2];
root -> 2 [minlen=2];
root -> 3 [minlen=2];
root -> 4 [minlen=2];
root -> 5 [minlen=2];
root -> 6 [minlen=2];
root -> 7 [minlen=2];
root -> 8 [minlen=2];
root -> 9 [minlen=2];
root -> "." [minlen=2];
g -> ga ;
g -> gb ;
g -> gc ;
g -> gd ;
g -> ge ;
g -> gf ;
g -> gg ;
g -> gh ;
g -> gi ;
g -> gj ;
g -> gk ;
g -> gl ;
g -> gm ;
g -> gn ;
g -> go ;
g -> gp ;
g -> gq ;
g -> gr ;
g -> gs ;
g -> gt ;
g -> gu ;
g -> gv ;
g -> gw ;
g -> gx ;
g -> gy ;
ga -> gaa ;
ga -> gab ;
ga -> gac ;
ga -> gad ;
ga -> gae ;
ga -> gaf ;
ga -> gag ;
ga -> gah ;
ga -> gai ;
ga -> gaj ;
ga -> gak ;
ga -> gal ;
ga -> gam ;
ga -> gan ;
ga -> gao ;
ga -> gap ;
ga -> gaq ;
ga -> gaz ;
ga -> gas ;
ga -> gat ;
ga -> gau ;
ga -> gav ;
ga -> gaw ;
ga -> gax ;
ga -> gay ;
gaz -> gaza ;
gaz -> gazb ;
gaz -> gazc ;
gaz -> gazd ;
gaz -> gaze ;
gaz -> gazf ;
gaz -> gazg ;
gaz -> gazh ;
gaz -> gazi ;
gaz -> gazj ;
gaz -> gazk ;
gaz -> gazl ;
gaz -> gazm ;
gaz -> gazn ;
gaz -> gazo ;
gaz -> gazp ;
gaz -> gazq ;
gaz -> gazr ;
gaz -> gazs ;
gaz -> gazt ;
gaz -> gazu ;
gaz -> gazv ;
gaz -> gazw ;
gaz -> gazx ;
gaz -> gazy ;
gazo -> "Blue Tuesday" ;
"Blue Tuesday" [ fontsize=10];
// Layout engines: circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
}
This output is generated with:
twopi -os1.png -Tpng s1.dot
I'm posting here because the printout is pretty dreadful. All of the nodes hung of "gaz" are overlapping; I've tried specifying nodesep and it is simply ignored. I would like to see the lines from root to the single letters further apart, but again, I can't control that.
This seems to be a bug in twopi. The documentation says it should clearly follow these directives, but it doesn't seem to.
My questions:
Is there any way to make twopi behave?
Failing that, is there a better layout engine to use?
Thanks.
I have found twopi to be the most difficult to work with of all the graphviz layout engines.
I made a few small changes to your original dot file. The rendered graph is shown below.
Here are the diffs:
graph attributes:
size="7.75,10.25"; // ensures that
entire graph fits on a single 8.5 x
11 page;
orientation="landscape";
ranksep=3.0; nodesep=2.0;
deleted: "root=root"; and
"overlap=true"
edge attributes:
i set the edge weight equal to 0.1
for all edges: [weight=0.1]
Reducing the edge weight by 90% for all edges has the net effect of increasing the edge length (or more precisely relaxing the constraint on edge length); obviously, this helps the nodes to "fan out". Doing this also increases the distance between "g" and "root", giving the child nodes of "root" more room.
I also tweaked a few purely aesthetic attributes--not having any effect on the layout, but that to me, seem to matter when you need to draw even a moderately dense graph on a single page:
graph attributes:
fontname="Helvetica";
fontsize=13
node attributes:
"root" [color="goldenrod4", shape="diamond", style="filled"]
"g" [color="lightsteelblue2", shape="diamond", style="filled"]
"ga" [color="darkorange", shape="diamond", style="filled"]
"gaz" [color="bisque4", shape="diamond", style="filled"]
edge attributes:
[arrowsize=0.4, penwidth=1.2]

How to force position of edges in graphviz?

I'm having problems with edges overlapping each other. In my previous question of how to force the nodes to be in the same column, found out how to force the nodes in to one column, but this causes some other problems to appear.
digraph exmp {
A -> B -> C -> D -> E
C -> F [constraint=false]
A -> C [style="dotted", constraint=false]
A -> D [style="dotted", constraint=false]
B -> D [constraint=false]
D -> A [style="dashed", constraint=false]
C -> A [style="dashed", constraint=false]
E -> F [style="invis"]
F -> G
E -> C [constraint="false"]
}
Renders to:
alt text http://img98.imageshack.us/img98/8324/wrong2.gif
My problem is that the edges from E -> C and C -> F are starting/ending at the same point in the node C and the dashed and dotted edges are all on the right side of the nodes.
How could I tell specific edges to go to the right side of the node?
After a message in the graphviz mail list I've found that's at least possible to remove the E -> C and C -> F overlapping problem.
The simplest solution is to use a
compass point port:
C:e -> F [constraint=false]
-- Emden

Resources