Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #37881 > unrolled thread
| Started by | Jan Coombs <Jan-54 <jenfhaomndgfwutc@murmic.plus.com>> |
|---|---|
| First post | 2015-04-03 12:07 +0100 |
| Last post | 2015-04-03 12:03 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.forth
gforth mmap - can't connect? Jan Coombs <Jan-54 <jenfhaomndgfwutc@murmic.plus.com>> - 2015-04-03 12:07 +0100
Re: gforth mmap - can't connect? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-03 12:03 +0000
| From | Jan Coombs <Jan-54 <jenfhaomndgfwutc@murmic.plus.com>> |
|---|---|
| Date | 2015-04-03 12:07 +0100 |
| Subject | gforth mmap - can't connect? |
| Message-ID | <20150403120733.5b82aa6a@T60A> |
I want to connect support tools for Forth chips like the
b16 and j1 to my development tools, so that I can
interactively write code and debug on a simulation of the
hardware. The tools can the be later connected to the
FPGA hardware to continue testing at higher speed.
Small FPGA boards often include a USB comm port for debug,
so there is no problem connecting tools to real chip, but
in order to connect up for simulation I need a byte-wide
bi-directional pipe. To make this easy to port to Windows
I chose to implement this myself using mmap.
Getting this working at the chip tools end, in Python, was
not too difficult, but I cannot seem to get it connecting
in gforth. The mmap'd file has only one writer.
This is the read end setup in Python:
import os
fd_in = os.open('/home/jan/tmp/mmaptest', os.O_RDONLY)
buf = mmap.mmap(fd_in, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_READ)
This is my gforth read setup:
include mmap_0.7.9.fs
s" /home/jan/tmp/mmaptest" r/o open-file throw Value fd_in
here >pagealign here - allot
here pagesize allot constant buf
\ buf pagesize PROT_READ MAP_SHARED fd_in off mmap
\ buf pagesize PROT_READ MAP_SHARED fd_in -1 mmap
buf pagesize PROT_READ MAP_SHARED fd_in 0 mmap
I do not know what 'iff' is, and having looked at mmap docs
for C still can't guess. Or perhaps my problem is elsewhere?
I'm not seeing any errors, but buff remains empty, while I
can see another receiver working correctly.
The gforth version is Gforth 0.7.0, running under ubuntu.
Any ideas, updated source or docs, would be appreciated.
Jan Coombs
--
email valid, else fix dots and hyphen
jan4clf2014@murrayhyphenmicroftdotcodotuk
[toc] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-04-03 12:03 +0000 |
| Message-ID | <2015Apr3.140316@mips.complang.tuwien.ac.at> |
| In reply to | #37881 |
Jan Coombs <Jan-54 <jenfhaomndgfwutc@murmic.plus.com>> writes:
>This is my gforth read setup:
>
>include mmap_0.7.9.fs
>s" /home/jan/tmp/mmaptest" r/o open-file throw Value fd_in
>here >pagealign here - allot
>here pagesize allot constant buf
>\ buf pagesize PROT_READ MAP_SHARED fd_in off mmap
>\ buf pagesize PROT_READ MAP_SHARED fd_in -1 mmap
> buf pagesize PROT_READ MAP_SHARED fd_in 0 mmap
>
>I do not know what 'iff' is, and having looked at mmap docs
>for C still can't guess.
If your question is what the offset parameter of mmap is, the
documentation says this:
The contents of a file mapping (as opposed to an anonymous mapping; see
MAP_ANONYMOUS below), are initialized using length bytes starting at
offset offset in the file (or other object) referred to by the file
descriptor fd.
0 is probably what you want.
> Or perhaps my problem is elsewhere?
open-file returns a FILE *, not an int. You need fileno to convert it
into an int, or you open the file with the system call open.
You probably should specify 0 instead of buf (so the OS can select a
free address region). The address of the mapping is returned as
result.
Depending on how mmap is defined, offset might be expected to be a
double; if so, use 0. instead of 0 for the offset parameter.
>I'm not seeing any errors
Do you get a non-zero result out of mmap?
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2014: http://www.euroforth.org/ef14/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.forth
csiph-web