Foreign types in Allegro CL

From: Craig Sauer (craig.sauer_at_gmail.com)
Date: 11/24/04


Date: 24 Nov 2004 14:14:05 -0800

I'm fairly new to Lisp, and this is my first posting here. I'd
appreciate any advice on this problem I'm having:

I'm passing data back and forth between two applications (currently
both on the same computer) via UDP.

The Lisp program needs to receive a packet of 16 bytes, consisting of
an integer, a double, and another integer. I am receiving the packet
just fine, and I can print out each byte's value individually.

I'm using Allegro CL's foreign types facility, with commands like:

(setf int1test (ff:fslot-value-typed :int :lisp (subseq data 0 4)))
(setf doubletest (ff:fslot-value-typed :double :lisp (subseq data 4
12)))
(setf int2test (ff:fslot-value-typed :int :lisp (subseq data 12)))

to convert the 16 bytes in "data" into the int, double, int, that I'm
expecting.

When I print out these 3 values, using code like:

(format t "~D " int1test)
(format t "~F " doubletest)
(format t "~D~%" int2test)

The integers print out fine, but the double is unrecognizable. I've
tried swapping the bytes in case there is an endian issue at work (but
I doubt it because the integers are ok).

An example:

I send 5, 7.0, 10 ten times

the Lisp program responds: (the third line of every set is the 16
bytes)

Packet 1 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

Packet 2 ->16 bytes from 2130706433
5 -1.6958247478583448d+216 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

Packet 3 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

Packet 4 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

Packet 5 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

Packet 6 ->16 bytes from 2130706433
5 1.5069781534728802d-154 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

Packet 7 ->16 bytes from 2130706433
5 -6.591781867590727d-213 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

Packet 8 ->16 bytes from 2130706433
5 1.4951352948556237d-154 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

Packet 9 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

Packet 10 ->16 bytes from 2130706433
5 -5.880343017059636d-39 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0

I can see that the 16 bytes are the same on each cycle, but I'm
getting a different (incorrect) double on every cycle.

I would appreciate any help on this problem.

Sincerely,

Craig Sauer



Relevant Pages

  • Re: Rewrap "> " lines from file ?
    ... Common Lisp, as that is much easier to use for stand-alone processing. ... Anyway, once you have paragraphs, you can use a fancy Common Lisp format ... A fancier form of this function would allow you to specify the prefix ... language, then what you should do is write a rule-based reformatter, and ...
    (comp.lang.lisp)
  • Re: editor for direct editing of the syntax tree: possible?
    ... but the raw structure of lisp sources are BINARY ... So you need to have an idea of the abstract syntax, ... how to indent the source. ... since the user must format the text like in any other emacs. ...
    (comp.lang.lisp)
  • Re: So what is the right way to write string.join?
    ... After giving up on format as being too cute, ... (The fact that concatenate takes the things to concatenate as a restarg is starting to look like a bad design decision.) ... So what is the Right Way to write this function in Lisp, where Right Way is defined as the way that produces reasonable runtime performance with no arbitrary limit on the size of the input list without writing too much code. ...
    (comp.lang.lisp)
  • Newbee: Lispy alternatives for configuration information file
    ... I currently have a program that stores configuration information ... in a modified window's INI file format. ... read at runtime and loads internal values and arrays. ... to utilize the lisp reader facilities, but not make the data appear ...
    (comp.lang.lisp)
  • Re: Daft idea?
    ... But even still with the Lisp way, it is a design choice, it's just one that ... Even as far as storing the rows in a Comma Seperated Value format can handle ... sophisticated database servers jump through a myriad of hoops to ...
    (comp.lang.forth)