Re: Startup files for STM32F4xx

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn

On Saturday, 25 April 2015 at 06:25:08 UTC, tom wrote:

On Saturday, 25 April 2015 at 04:01:47 UTC, Jens Bauer wrote:
(still no automatic mirroring, though I've installed 
https://github.com/miracle2k/gitolite-simple-mirror)

it should be fairly simple, check the logs.


It's probably something silly being wrong. The logs does not 
report any errors, except for that stupid line I always get from 
gitweb:

CGI::param called in list context from package main line 874
(they promised that it was fixed in v2.1, but I'm on 2.3.6 and it 
still spams my Apache error-log).


The gitolite-log also seems to be fine.


most probably something failing with authentication.


I tried a manual clone from the 'd' server's account, it seems to 
clone without problems (and there's no passphrase blocking it 
from completing)


another approach would be that you just add the github as a 
second remote repository and push to both (e.g. via a simple 
shell alias in your shells rc file)


So far, I made a small script that mirrors when I run it. I could 
also add a cron-job on the server until I find a solution; but I 
think I'll stick to the manual mirror until I find out what the 
problem is.


i'm mostly on os x / archlinux. both contain packages for 
openocd.
i just did a ```brew install openocd --HEAD``` and it installed 
smoothly.


That's great. Did you build GDC or LDC for arm-none-eabi already ?

If you have built the compiler too, then I think you're all set.
The linker-scripts should work fine and the startup file is ready 
for use.
What's still missing is some kind of portable Makefile. My own 
Makefile seem to be too complex to port. It might be best to 
start from scratch with a simple Makefile.


Re: Startup files for STM32F4xx

2015-04-24 Thread tom via Digitalmars-d-learn

On Saturday, 25 April 2015 at 04:01:47 UTC, Jens Bauer wrote:
(still no automatic mirroring, though I've installed 
https://github.com/miracle2k/gitolite-simple-mirror)

it should be fairly simple, check the logs.
most probably something failing with authentication.
(btw, for those who don't know it: https://github.com/gogits/gogs 
more or less a simplified github clone that runs as a single 
binary, pretty neat)


another approach would be that you just add the github as a 
second remote repository and push to both (e.g. via a simple 
shell alias in your shells rc file)



i'm mostly on os x / archlinux. both contain packages for openocd.
i just did a ```brew install openocd --HEAD``` and it installed 
smoothly.


Re: Startup files for STM32F4xx

2015-04-24 Thread Rikki Cattermole via Digitalmars-d-learn

On 25/04/2015 5:07 p.m., Jens Bauer wrote:

On Saturday, 25 April 2015 at 04:21:06 UTC, Martin Nowak wrote:

The STM peripheral library really sux, verbose boilerplate for the
simplest stuff and no type safety for the enums (find the difference
of GPIO_PIN4 and GPIO_PinSource4 via debugging).


I couldn't agree more. I especially hate the fact that pointers have to
be type-casted into uint32_t!

I know, I know.. It's always 32-bit on the Cortex-M microcontrollers,
but ... it would make it easier to make a sandbox application or some
test-suite running on a computer, if not having to type-cast everything.


It's also really hard to setup all the startup files, linker scripts
and debugger configs.

In constrast we could provide a really amazing D experience on those
platforms.


D is really suitable for microcontrollers; especially because classes no
longer cost a payload of memory. This will allow us to make neat
User-Interface objects easily, where a minimal UI library would be 5K in
C++. I also hope that associative arrays and strings will fit most
microcontrollers. I know that there might be problems, when we have
little RAM available. I do not know how little memory is realistic at
the moment; here I'm especially thinking about fragmentation and the use
of the 'new' keyword.

I hope to find a good way to use import for microcontroller libraries,
so it'll be easy for everyone. I'm thinking about something like ...

import mcu.stm32f439.all


Ugh, package.d?


... and I'm hoping to have this in a shared location instead of
including the library in every source file like it's usually done in C
and C++ based projects. But I will wait and see what the more
experienced D)everlopers recommend. ;)

While I remember it ... I had to nullify a number of imports in stdint.
They simply do not belong in there. :)
Eg. I do not want FILE* if I aks for stdint. But FILE* is forced upon
me, because wchar_t includes it. What does a wchar_t need a file-system
for ?
Things like these might need a slight cleanup at some point (because
normally, you don't have a file system on a microcontroller; thus you
will get errors, when trying to import a simple file like stdint).




Re: Startup files for STM32F4xx

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn

On Saturday, 25 April 2015 at 04:21:06 UTC, Martin Nowak wrote:
The STM peripheral library really sux, verbose boilerplate for 
the simplest stuff and no type safety for the enums (find the 
difference of GPIO_PIN4 and GPIO_PinSource4 via debugging).


I couldn't agree more. I especially hate the fact that pointers 
have to be type-casted into uint32_t!


I know, I know.. It's always 32-bit on the Cortex-M 
microcontrollers, but ... it would make it easier to make a 
sandbox application or some test-suite running on a computer, if 
not having to type-cast everything.


It's also really hard to setup all the startup files, linker 
scripts and debugger configs.


In constrast we could provide a really amazing D experience on 
those platforms.


D is really suitable for microcontrollers; especially because 
classes no longer cost a payload of memory. This will allow us to 
make neat User-Interface objects easily, where a minimal UI 
library would be 5K in C++. I also hope that associative arrays 
and strings will fit most microcontrollers. I know that there 
might be problems, when we have little RAM available. I do not 
know how little memory is realistic at the moment; here I'm 
especially thinking about fragmentation and the use of the 'new' 
keyword.


I hope to find a good way to use import for microcontroller 
libraries, so it'll be easy for everyone. I'm thinking about 
something like ...


import mcu.stm32f439.all

... and I'm hoping to have this in a shared location instead of 
including the library in every source file like it's usually done 
in C and C++ based projects. But I will wait and see what the 
more experienced D)everlopers recommend. ;)


While I remember it ... I had to nullify a number of imports in 
stdint. They simply do not belong in there. :)
Eg. I do not want FILE* if I aks for stdint. But FILE* is forced 
upon me, because wchar_t includes it. What does a wchar_t need a 
file-system for ?
Things like these might need a slight cleanup at some point 
(because normally, you don't have a file system on a 
microcontroller; thus you will get errors, when trying to import 
a simple file like stdint).


Re: Startup files for STM32F4xx

2015-04-24 Thread Martin Nowak via Digitalmars-d-learn

On Saturday, 25 April 2015 at 01:32:16 UTC, Jens Bauer wrote:
This is most likely where the egg cracks open. i'm pretty sure 
we willl see people migrating to using D (at first a mixture 
between D and C, because of the libraries from the vendors), 
but later, there'll surely be projects which are pure D. -After 
all, it's not difficult to convert a library file from C to D. 
:)


The STM peripheral library really sux, verbose boilerplate for 
the simplest stuff and no type safety for the enums (find the 
difference of GPIO_PIN4 and GPIO_PinSource4 via debugging).
It's also really hard to setup all the startup files, linker 
scripts and debugger configs.


In constrast we could provide a really amazing D experience on 
those platforms.


Re: Startup files for STM32F4xx

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 02:02:35 UTC, Rikki Cattermole 
wrote:

Congrats!


Thank you. :)


Also I found this, https://github.com/defunkt/github-gem


Looks interesting. Maybe this can make things easier.

I created a repository for people who work with LPC17xx:
https://github.com/jens-gpio/LPC17xx
(still no automatic mirroring, though I've installed 
https://github.com/miracle2k/gitolite-simple-mirror)


Re: How to output ascii character using terminal.d

2015-04-24 Thread Cassio Butrico via Digitalmars-d-learn

On Friday, 24 April 2015 at 22:21:16 UTC, Adam D. Ruppe wrote:
Also try cast(dchar) instead of cast(char), that might do what 
you need.


a look at this
https://github.com/cassio2014/DIC


Re: Startup files for STM32F4xx

2015-04-24 Thread Rikki Cattermole via Digitalmars-d-learn

On 25/04/2015 12:54 p.m., Jens Bauer wrote:

... I now succeeded in making a mirror on GitHub:
https://github.com/jens-gpio/STM32F4xx
(It was absolutely tedious, because the tutorial on GitHub didn't work
for me; I haven't yet added automatic mirroring; hopefully I'll be able
to figure it out).


Congrats!

Also I found this, https://github.com/defunkt/github-gem


Re: Startup files for STM32F4xx

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn

On Saturday, 25 April 2015 at 01:06:16 UTC, Mike wrote:
On Saturday, 25 April 2015 at 00:33:26 UTC, Steven 
Schveighoffer wrote:

Due to its large number of pins, and the way they are arranged,
they don't plug into breadboards, but you can easily use jumper
wires for that: https://www.adafruit.com/products/153.


If you can 'afford to wait', you can get those for a very low 
price on eBay:

http://shop.ebay.com/dupont%20male%20female
-It may take between 5 days and 2 months before they arrive, 
depending on which way the wind is blowing... ;)



There's quite a few "Discovery" boards from ST {snip}


Yes, the STM32F446 is the newest; I really should have mentioned 
this board. It's quite a good chip too.


It's quite exciting to see Jens's work and the expressed 
interest in using D for this domain.  I hope to see more.


This is most likely where the egg cracks open. i'm pretty sure we 
willl see people migrating to using D (at first a mixture between 
D and C, because of the libraries from the vendors), but later, 
there'll surely be projects which are pure D. -After all, it's 
not difficult to convert a library file from C to D. :)


I think I just got automatic mirroring working. It seems it's 
only a single line in the Gitolite conf. :)


Re: Startup files for STM32F4xx

2015-04-24 Thread Mike via Digitalmars-d-learn
On Saturday, 25 April 2015 at 00:33:26 UTC, Steven Schveighoffer 
wrote:



http://www.digikey.com/product-search/en?x=0&y=0&lang=en&site=us&keywords=stm32f429+discovery


This is super tempting @ $24. As someone who is not used to 
tinkering with raw hardware, how does one power this thing? 
I've tinkered with SBCs, but those had full-blown Linux. What 
hardware is necessary to get this thing running?


-Steve


It's powered from your PC's USB port (Using one right now, 
actually).  No extra hardware is needed unless you want to add 
features beyond what the board provides. Due to its large number 
of pins, and the way they are arranged, they don't plug into 
breadboards, but you can easily use jumper wires for that: 
https://www.adafruit.com/products/153.


I have a basic D demo for this board here: 
https://github.com/JinShil/stm32f42_discovery_demo.  It's just a 
blinky app at the moment, but it does all the work of configuring 
the clocks, flash, etc... before calling the "main" function.


There's quite a few "Discovery" boards from ST 
(http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1848?icmp=ln1848_pron_pr-stm32f446_dec2014&sc=stm32discovery-pr) 
as well as boards from other manufacturers 
(http://www.mikroe.com/stm32/development-boards/).


It's quite exciting to see Jens's work and the expressed interest 
in using D for this domain.  I hope to see more.


Mike


Re: Startup files for STM32F4xx

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 00:33:26 UTC, Steven Schveighoffer 
wrote:

On 4/24/15 7:42 PM, Jens Bauer wrote:


http://www.digikey.com/product-search/en?x=0&y=0&lang=en&site=us&keywords=stm32f429+discovery


This is super tempting @ $24. As someone who is not used to 
tinkering with raw hardware, how does one power this thing?


Simply via the USB-port on the computer or a 5V USB-plug power 
supply. :)


I've tinkered with SBCs, but those had full-blown Linux. What 
hardware is necessary to get this thing running?


Virtually just the board itself.
-The Discovery boards have a built-in ST-Link v2 SWD programmer, 
so you can use OpenOCD directly with the board. The only thing 
you need is the USB-to-USB-mini cable, which is something you can 
get almost everywhere.


... I now succeeded in making a mirror on GitHub:
https://github.com/jens-gpio/STM32F4xx
(It was absolutely tedious, because the tutorial on GitHub didn't 
work for me; I haven't yet added automatic mirroring; hopefully 
I'll be able to figure it out).


Re: Startup files for STM32F4xx

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/24/15 7:42 PM, Jens Bauer wrote:

On Friday, 24 April 2015 at 22:18:22 UTC, tom wrote:


ill order a discover, i have to try this out.
http://www.digikey.com/product-detail/en/STM32F4DISCOVERY/497-11455-ND/2711743

this one right?


This board will do nicely, but you may want to get a STM32F29 discovery
board, because the STM32F429 support higher speeds, has more features,
more on-chip SRAM and more freedom. :)
LCD/TFT support and Chrom-ART are two of my favorite features.
The STM32F429 discovery board has 64MB external SDRAM as well.

http://www.digikey.com/product-search/en?x=0&y=0&lang=en&site=us&keywords=stm32f429+discovery


This is super tempting @ $24. As someone who is not used to tinkering 
with raw hardware, how does one power this thing? I've tinkered with 
SBCs, but those had full-blown Linux. What hardware is necessary to get 
this thing running?


-Steve


Re: Degenerate Regex Case

2015-04-24 Thread TheFlyingFiddle via Digitalmars-d-learn

On Friday, 24 April 2015 at 18:28:16 UTC, Guillaume wrote:
Hello, I'm trying to make a regex comparison with D, based off 
of this article: https://swtch.com/~rsc/regexp/regexp1.html


I've written my code like so:

import std.stdio, std.regex;

void main(string argv[]) {

string m = argv[1];
	auto p = 
ctRegex!("a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaa");

if (match(m, p)) {
writeln("match");
} else {
writeln("no match");
}

}

And the compiler goes into swap. Doing it at runtime is no 
better. I was under the impression that this particular regex 
was used for showcasing the Thompson NFA which D claims to be 
using.


The regex 
"a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaa" 
can be simplified to "a{30,60}" (if i counted correctly).


The regex "a{30,60}" works fine.

[Speculation]
I don't have a good understanding of how D's regex engine work 
but I am guessing that it does not do any simplification of the 
regex input causing it to generate larger engines for each 
additional ? symbol. Thus needing more memory. Eventually as in 
this case the compiler runs out of memory.







Re: Startup files for STM32F4xx

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn

On Friday, 24 April 2015 at 22:18:22 UTC, tom wrote:


ill order a discover, i have to try this out.
http://www.digikey.com/product-detail/en/STM32F4DISCOVERY/497-11455-ND/2711743
this one right?


This board will do nicely, but you may want to get a STM32F29 
discovery board, because the STM32F429 support higher speeds, has 
more features, more on-chip SRAM and more freedom. :)

LCD/TFT support and Chrom-ART are two of my favorite features.
The STM32F429 discovery board has 64MB external SDRAM as well.

http://www.digikey.com/product-search/en?x=0&y=0&lang=en&site=us&keywords=stm32f429+discovery

Also available from newark (06X3667) / farnell (2355377)

-But the most important thing is that you have a working 
toolchain.
OpenOCD v0.9.0 just went RC1 today, so it's easy for everyone to 
build it.
Freddie Chopin already made a Windows binary (as usual), so if 
you're using Windows, I recommend getting his binary from ...

http://www.freddiechopin.info/en/download/category/10-openocd-dev
... otherwise you'll need to build it from the git repository. I 
recommend using v0.9.0 over any previous version, because there 
are several fixes for STM and LPC in v0.9.0 (OpenOCD also works 
well on big endian hosts now).


-So get all the free stuff working before you make a purchase 
(including the linker scripts).
You should be able to use arm-none-eabi-objdump -D for 
disassembling your .elf file.


Re: Startup files for STM32F4xx

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn
On Friday, 24 April 2015 at 12:55:46 UTC, Steven Schveighoffer 
wrote:


I was hoping that github access would be possible now with a 
more modern browser, no?


Actually I was getting sleepy and had to do something else the 
next day, so I couldn't start right away.
But I'll have to learn using GitHub - I've never used it before, 
due to the problems, so I'm a newbie here (feels strange to be a 
newbie after being a nerd for so long). I'll try and see if I can 
find out how to mirror my repository and will post a note here if 
I succeed. :)


I want to say, I remember Mike's talk last year, and having 
worked with ST7 micros (small ones, not even close to being 
supportable by D), I thought it was the coolest thing.


Mike's examples and talk was very inspiring. If he hadn't made 
these, I would probably not have gotten "hungry" for starting my 
D-support on microcontrollers.
-But showing that "it's basically possible" meant a huge 
difference.


I am very excited to see a possibility of using D for embedded 
programming. This really could be a niche win for D!


I couldn't agree more. D has so many advantages over C and C++ on 
microcontrollers. :)
I hope that I can get a "low-cost" support for associative 
arrays. When I say low-cost, I mean something like using a 
minimal malloc/free, in order to reduce the final binary.
(I've written a minimal malloc/free/realloc in C already, it's 
stress-tested and in use in someone else's application at the 
moment, so it may be ready for porting already)


Re: How to output ascii character using terminal.d

2015-04-24 Thread Adam D. Ruppe via Digitalmars-d-learn
Also try cast(dchar) instead of cast(char), that might do what 
you need.


Re: Startup files for STM32F4xx

2015-04-24 Thread tom via Digitalmars-d-learn

On Friday, 24 April 2015 at 13:12:56 UTC, Jens Bauer wrote:

On Friday, 24 April 2015 at 07:34:55 UTC, tom wrote:

would something like a STM32 NUCLEO-F401RE work?


I forgot to give you a proper answer on this one: I think it 
should work, as it's a STM32F401 microcontroller.




ill order a discover, i have to try this out.
http://www.digikey.com/product-detail/en/STM32F4DISCOVERY/497-11455-ND/2711743
this one right?



Re: md5 return toHexString

2015-04-24 Thread Johannes Pfau via Digitalmars-d-learn
Am Fri, 24 Apr 2015 18:02:57 +
schrieb "AndyC" :

> On Friday, 24 April 2015 at 17:56:59 UTC, tcak wrote:
> > On Friday, 24 April 2015 at 17:50:03 UTC, AndyC wrote:
> >> Hi All, I cannot seem to understand whats wrong with this:
> >>
> >> // main.d
> >> import std.stdio;
> >> import std.digest.md;
> >> import std.file;
> >>
> >>
> >> string md5sum(const string fname)
> >> {
> >>MD5 hash;
> >>
> >>File f = File(fname, "rb");
> >>foreach( ubyte[] buf; f.byChunk(4096))
> >>{
> >>hash.put(buf);
> >>}
> >>
> >>string s = toHexString!(LetterCase.lower)(hash.finish());
> >>writeln(s);   //This is correct
> >>return s;
> >> }
> >>
> >> void main()
> >> {
> >>string crc = md5sum("main.d");
> >>writeln(crc);  //This is garbage
> >> }
> >>
> >>
> >> The writeln in md5sum prints correctly, but the "return s" 
> >> seems to mess it up?  What's going on?
> >>
> >> Thanks for you time,
> >>
> >> -Andy
> >
> > Just do that "return s.dup()". Then it works for me. That's 
> > probably due to the fact that s is in stack. But I am not sure 
> > how "toHexString" works.
> 
> 
> Ah, yep, that works.  I'd originally written it as:
> return toHexString!(LetterCase.lower)(hash.finish());
> 
> Which doesn't work, so used the temp string to test it.
> 
> Now I'm using:
> return toHexString!(LetterCase.lower)(hash.finish()).dup();
> 
> Kinda weird.  But works.  Thank you!
> 
> -Andy

https://issues.dlang.org/show_bug.cgi?id=9279

toHexstring doesn't return a string, it returns char[n], a fixed-size
array of length n. It shouldn't implicitly convert to a string.


Re: Weird OSX issue

2015-04-24 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-04-24 20:37, Steven Schveighoffer wrote:


So am I going crazy? Or is dmd doing things differently depending on
where its environment is? Any compiler gurus out there understand why
the symbol is different?

I don't want to file a bug with this, because it seems dependent on
installation location, would possibly not be reproducible.


I can't reproduce this with DMD from DVM (compiler is installed in the 
user home directory).


--
/Jacob Carlborg


Re: How to output ascii character using terminal.d

2015-04-24 Thread Paul via Digitalmars-d-learn

On Friday, 24 April 2015 at 15:46:15 UTC, Adam D. Ruppe wrote:
Try terminal.writef("%s", cast(char) your_ascii_character); it 
should work.


Thank you, it works for the standard ascii characters but not the 
extended set - maybe that has something to do with my terminal 
settings...? (not that I know how to change them anyway!)


Paul


Re: Convert hex to binary

2015-04-24 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 24 April 2015 at 18:55:07 UTC, Steven Schveighoffer 
wrote:
Thanks to all of you for the solutions, but what if the 
hex-string

exceeds the limit of ulong, for instance
"123456789ABCDEF0123456789ABCDEF1234". How to convert them to a
ulong-array?


Well, technically, a hex string can be split on 16-character 
boundaries, and then you could parse each one.


-Steve


BigInt can be constructed from a decimal string:

-
import std.bigint, std.conv, std.stdio, std.string;
void main(){readln.strip.to!BigInt.writeln;}
-

The same could have been done in the library for function "to" 
accepting the second argument, like this:


-
import std.bigint, std.conv, std.stdio, std.string;
void main(){readln.strip.to!BigInt(16).writeln;}
-

It seems trivial technically, but I wonder if there's some 
library design drawback.  After all, to!BigInt from the default 
base 10 is the same O(n^2) as to!BigInt from a variable base, so 
it's not like the function is going to hide complexity more than 
it already does.


Ivan Kazmenko.


Re: Convert hex to binary

2015-04-24 Thread Rene Zwanenburg via Digitalmars-d-learn

On Friday, 24 April 2015 at 19:15:04 UTC, Ivan Kazmenko wrote:
On Friday, 24 April 2015 at 18:55:07 UTC, Steven Schveighoffer 
wrote:
Thanks to all of you for the solutions, but what if the 
hex-string

exceeds the limit of ulong, for instance
"123456789ABCDEF0123456789ABCDEF1234". How to convert them to 
a

ulong-array?


Well, technically, a hex string can be split on 16-character 
boundaries, and then you could parse each one.


-Steve


BigInt can be constructed from a decimal string:

-
import std.bigint, std.conv, std.stdio, std.string;
void main(){readln.strip.to!BigInt.writeln;}
-

The same could have been done in the library for function "to" 
accepting the second argument, like this:


-
import std.bigint, std.conv, std.stdio, std.string;
void main(){readln.strip.to!BigInt(16).writeln;}
-

It seems trivial technically, but I wonder if there's some 
library design drawback.  After all, to!BigInt from the default 
base 10 is the same O(n^2) as to!BigInt from a variable base, 
so it's not like the function is going to hide complexity more 
than it already does.


Ivan Kazmenko.


ATM BigInt already supports hex strings; it looks for a 0x 
prefix. A radix parameter would be nice, but this works today ;)


Re: Convert hex to binary

2015-04-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 24 April 2015 at 18:55:07 UTC, Steven Schveighoffer 
wrote:

On 4/24/15 2:50 PM, nrgyzer wrote:

On Friday, 24 April 2015 at 18:45:55 UTC, Jesse Phillips wrote:

On Friday, 24 April 2015 at 18:14:07 UTC, nrgyzer wrote:

Hi,

I'm looking for a function that converts my hex-string to a 
binary

representation. In Python I write the following:

myHex = "123456789ABCDEF"
myBin = myHex.decode('hex')

But how to do the same in D? Is there any function?

Thanks for suggestions!


   import std.stdio;
   void main(){
   import std.conv;
   import std.format;

   auto i = to!ulong("123456789ABCDEF", 16);

   writeln(format("%b", i));
   }


Thanks to all of you for the solutions, but what if the 
hex-string

exceeds the limit of ulong, for instance
"123456789ABCDEF0123456789ABCDEF1234". How to convert them to a
ulong-array?


Well, technically, a hex string can be split on 16-character 
boundaries, and then you could parse each one.


-Steve


Or use BigInt:

http://dlang.org/phobos/std_bigint.html


Re: __gshared static

2015-04-24 Thread via Digitalmars-d-learn
On Friday, 24 April 2015 at 18:05:22 UTC, Steven Schveighoffer 
wrote:
On 4/24/15 1:22 PM, "=?UTF-8?B?Ik3DoXJjaW8=?= Martins\" 
\"" wrote:

Hi!

I just stumbled across what seems like a misunderstanding on 
my side

about these keywords. Can someone help clarify these for me?

```
__gshared static int foo;
__gshared int foo;
```

What are the storage and semantic differences between those 
two, if any?


These are the same, __gshared overrides static.

-Steve


Thanks Steve!


Re: Convert hex to binary

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/24/15 2:50 PM, nrgyzer wrote:

On Friday, 24 April 2015 at 18:45:55 UTC, Jesse Phillips wrote:

On Friday, 24 April 2015 at 18:14:07 UTC, nrgyzer wrote:

Hi,

I'm looking for a function that converts my hex-string to a binary
representation. In Python I write the following:

myHex = "123456789ABCDEF"
myBin = myHex.decode('hex')

But how to do the same in D? Is there any function?

Thanks for suggestions!


import std.stdio;
void main(){
import std.conv;
import std.format;

auto i = to!ulong("123456789ABCDEF", 16);

writeln(format("%b", i));
}


Thanks to all of you for the solutions, but what if the hex-string
exceeds the limit of ulong, for instance
"123456789ABCDEF0123456789ABCDEF1234". How to convert them to a
ulong-array?


Well, technically, a hex string can be split on 16-character boundaries, 
and then you could parse each one.


-Steve


Re: __gshared static

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/24/15 2:47 PM, bearophile wrote:

Steven Schveighoffer:


These are the same, __gshared overrides static.


Isn't forbidding "__gshared static" a good idea then, to avoid user
confusion?


Surely, prohibiting non-functioning attributes is good when it's obvious 
that they do nothing.


BUT... there is an issue:

static: __gshared int x;

Should this be an error? I believe inside the compiler, the reason 
unused attributes are ignored are because this is handled the same way, 
and making it error would make all of them error. But that's kind of a 
guess.


-Steve



Re: Convert hex to binary

2015-04-24 Thread nrgyzer via Digitalmars-d-learn

On Friday, 24 April 2015 at 18:45:55 UTC, Jesse Phillips wrote:

On Friday, 24 April 2015 at 18:14:07 UTC, nrgyzer wrote:

Hi,

I'm looking for a function that converts my hex-string to a 
binary representation. In Python I write the following:


myHex = "123456789ABCDEF"
myBin = myHex.decode('hex')

But how to do the same in D? Is there any function?

Thanks for suggestions!


import std.stdio;
void main(){
import std.conv;
import std.format;

auto i = to!ulong("123456789ABCDEF", 16);

writeln(format("%b", i));
}


Thanks to all of you for the solutions, but what if the 
hex-string exceeds the limit of ulong, for instance 
"123456789ABCDEF0123456789ABCDEF1234". How to convert them to a 
ulong-array?


Re: Convert hex to binary

2015-04-24 Thread Jesse Phillips via Digitalmars-d-learn

On Friday, 24 April 2015 at 18:14:07 UTC, nrgyzer wrote:

Hi,

I'm looking for a function that converts my hex-string to a 
binary representation. In Python I write the following:


myHex = "123456789ABCDEF"
myBin = myHex.decode('hex')

But how to do the same in D? Is there any function?

Thanks for suggestions!


import std.stdio;
void main(){
import std.conv;
import std.format;

auto i = to!ulong("123456789ABCDEF", 16);

writeln(format("%b", i));
}


Re: __gshared static

2015-04-24 Thread bearophile via Digitalmars-d-learn

Steven Schveighoffer:


These are the same, __gshared overrides static.


Isn't forbidding "__gshared static" a good idea then, to avoid 
user confusion?


Bye,
bearophile


Re: Convert hex to binary

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/24/15 2:14 PM, nrgyzer wrote:

Hi,

I'm looking for a function that converts my hex-string to a binary
representation. In Python I write the following:

myHex = "123456789ABCDEF"
myBin = myHex.decode('hex')

But how to do the same in D? Is there any function?

Thanks for suggestions!


import std.conv : parse;
import std.stdio;

void main()
{
auto myHex = "123456789ABCDEF";
auto myBin = parse!ulong(myHex, 16);
writeln(myBin); // 81985529216486895
}

Note, python may make arbitrary long integers, but D you must specify 
the size for your integer to the parse function. In this case, you need 
ulong which is 64 bits.


-Steve



Re: No line numbers in compiler error messages

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/24/15 2:24 PM, Jesse Phillips wrote:

On Friday, 24 April 2015 at 17:20:12 UTC, John Nixon wrote:

I am using dmd v2.067.0 on Mac OSX with Terminal and I found the lack
of line numbers surprising.
Is there something simple I am doing wrong? Do any of the switches on
the command line do this?

BTW I only found out about D a couple of weeks back. It seems to be
very impressive!

John Nixon


Without debug symbols the line numbers aren't available (IIRC). Add -g
to your compile switches.


That's only for exceptions. Compiler always gives line numbers.

-Steve


Weird OSX issue

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
OK, so I think I found a bug, but I have no idea how to "reproduce" it. 
It seems to be dependent on environment.


Here is an annotated (using # for comments) session to show you the 
weirdness. All versions are 2.067, and I did use dmd -v to make sure 
rogue dmd.conf or library files are not playing any role, and that the 
files I compare below are being used. Please help figure this out :)


# This shows where dmd runs from when I use the command 'dmd'.
# this was installed using the dmg from dlang.org for 2.067
Stevens-MacBook-Pro:teststatic steves$ type dmd
dmd is hashed (/usr/bin/dmd)

# inside ~/Downloads/dmd2 is an unzipped copy of dmd 2.067. Note
# the binaries and libraries are identical (no output from cmp)
Stevens-MacBook-Pro:teststatic steves$ cmp /usr/bin/dmd 
~/Downloads/dmd2/osx/bin/dmd
Stevens-MacBook-Pro:teststatic steves$ cmp 
/usr/share/dmd/lib/libphobos2.a ~/Downloads/dmd2/osx/lib/libphobos2.a


# Now, checking concurrency.d text, also identical
Stevens-MacBook-Pro:teststatic steves$ diff 
/usr/share/dmd/src/phobos/std/concurrency.d 
~/Downloads/dmd2/src/phobos/std/concurrency.d


# and finally checking core.thread text, also identical
Stevens-MacBook-Pro:teststatic steves$ diff 
/usr/share/dmd/src/druntime/import/core/thread.d 
~/Downloads/dmd2/src/druntime/import/core/thread.d


# here is the program being compiled (I was testing something for a
# forum post)
Stevens-MacBook-Pro:teststatic steves$ cat mod1.d
module mod1;
import std.concurrency;
import std.stdio;

__gshared static int foo;

void main()
{
auto tid = spawn((Tid o){foo = 5; o.send(true);}, thisTid);
receiveOnly!bool();
writeln(foo);
}

# fails with /usr/bin/dmd
Stevens-MacBook-Pro:teststatic steves$ dmd mod1.d
Undefined symbols for architecture x86_64:
  "_D4core6thread6Thread5startMFZv", referenced from:

_D3std11concurrency61__T6_spawnTPFS3std11concurrency3TidZvTS3std11concurrency3TidZ6_spawnFbPFS3std11concurrency3TidZvS3std11concurrency3TidZS3std11concurrency3Tid 
in mod1.o

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

--- errorlevel 1

# so let's take a look at the symbol in mod1.o, see how it's
# specified. Looks like it was the same one identified as
# not being present
Stevens-MacBook-Pro:teststatic steves$ nm mod1.o | grep core6thread6Thread5
 U _D4core6thread6Thread5startMFZv

# works with identical compiler installed at ~/Donwloads/dmd2
Stevens-MacBook-Pro:teststatic steves$ ~/Downloads/dmd2/osx/bin/dmd mod1.d

# Same symbol? Nope! Note the difference seems to be in the parameter
# mangling.
Stevens-MacBook-Pro:teststatic steves$ nm mod1.o | grep core6thread6Thread5
 U _D4core6thread6Thread5startMFNbZC4core6thread6Thread

So am I going crazy? Or is dmd doing things differently depending on 
where its environment is? Any compiler gurus out there understand why 
the symbol is different?


I don't want to file a bug with this, because it seems dependent on 
installation location, would possibly not be reproducible.


-Steve


Degenerate Regex Case

2015-04-24 Thread Guillaume via Digitalmars-d-learn
Hello, I'm trying to make a regex comparison with D, based off of 
this article: https://swtch.com/~rsc/regexp/regexp1.html


I've written my code like so:

import std.stdio, std.regex;

void main(string argv[]) {

string m = argv[1];
	auto p = 
ctRegex!("a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaa");

if (match(m, p)) {
writeln("match");
} else {
writeln("no match");
}

}

And the compiler goes into swap. Doing it at runtime is no 
better. I was under the impression that this particular regex was 
used for showcasing the Thompson NFA which D claims to be using.


The golang code version of this runs fine, which makes me think 
that maybe D isn't using the correct regex engine for this 
particular regex. Or perhaps I'm using this wrong?


Re: Convert hex to binary

2015-04-24 Thread Ali Çehreli via Digitalmars-d-learn

On 04/24/2015 11:14 AM, nrgyzer wrote:

Hi,

I'm looking for a function that converts my hex-string to a binary
representation. In Python I write the following:

myHex = "123456789ABCDEF"
myBin = myHex.decode('hex')

But how to do the same in D? Is there any function?

Thanks for suggestions!


Here is one way:

import std.stdio;
import std.format;

string hexToBin(string source)
{
ulong value;
formattedRead(source, "%x", &value);
return format("%b", value);
}

enum string hex = "hex";

string decode(string TargetFormat)(string source)
{
static if (TargetFormat == "hex") {
return hexToBin(source);

} else {
static assert(false,
  format("I don't know how to decode to '%s'",
 TargetFormat));
return "";
}
}

void main()
{
assert("123456789ABCDEF".decode!hex ==
   "10010001101000101011000001001101010001100");
}

Ali



Re: No line numbers in compiler error messages

2015-04-24 Thread Jesse Phillips via Digitalmars-d-learn

On Friday, 24 April 2015 at 17:20:12 UTC, John Nixon wrote:
I am using dmd v2.067.0 on Mac OSX with Terminal and I found 
the lack of line numbers surprising.
Is there something simple I am doing wrong? Do any of the 
switches on the command line do this?


BTW I only found out about D a couple of weeks back. It seems 
to be very impressive!


John Nixon


Without debug symbols the line numbers aren't available (IIRC). 
Add -g to your compile switches.


Re: No line numbers in compiler error messages

2015-04-24 Thread John Nixon via Digitalmars-d-learn
On Friday, 24 April 2015 at 17:45:49 UTC, Steven Schveighoffer 
wrote:

On 4/24/15 1:20 PM, John Nixon wrote:
I am using dmd v2.067.0 on Mac OSX with Terminal and I found 
the lack of

line numbers surprising.
Is there something simple I am doing wrong? Do any of the 
switches on

the command line do this?


It does post line numbers. Please post source and compile line 
that causes this, and also result so it may be duplicated.


-Steve


My apologies, the problem was caused by the font colour (black) 
not visible with Terminal using a black background.


John Nixon


Convert hex to binary

2015-04-24 Thread nrgyzer via Digitalmars-d-learn

Hi,

I'm looking for a function that converts my hex-string to a 
binary representation. In Python I write the following:


myHex = "123456789ABCDEF"
myBin = myHex.decode('hex')

But how to do the same in D? Is there any function?

Thanks for suggestions!


Re: __gshared static

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/24/15 1:22 PM, "=?UTF-8?B?Ik3DoXJjaW8=?= Martins\" 
\"" wrote:

Hi!

I just stumbled across what seems like a misunderstanding on my side
about these keywords. Can someone help clarify these for me?

```
__gshared static int foo;
__gshared int foo;
```

What are the storage and semantic differences between those two, if any?


These are the same, __gshared overrides static.

-Steve


Re: md5 return toHexString

2015-04-24 Thread AndyC via Digitalmars-d-learn

On Friday, 24 April 2015 at 17:56:59 UTC, tcak wrote:

On Friday, 24 April 2015 at 17:50:03 UTC, AndyC wrote:

Hi All, I cannot seem to understand whats wrong with this:

// main.d
import std.stdio;
import std.digest.md;
import std.file;


string md5sum(const string fname)
{
   MD5 hash;

   File f = File(fname, "rb");
   foreach( ubyte[] buf; f.byChunk(4096))
   {
   hash.put(buf);
   }

   string s = toHexString!(LetterCase.lower)(hash.finish());
   writeln(s);   //This is correct
   return s;
}

void main()
{
   string crc = md5sum("main.d");
   writeln(crc);  //This is garbage
}


The writeln in md5sum prints correctly, but the "return s" 
seems to mess it up?  What's going on?


Thanks for you time,

-Andy


Just do that "return s.dup()". Then it works for me. That's 
probably due to the fact that s is in stack. But I am not sure 
how "toHexString" works.



Ah, yep, that works.  I'd originally written it as:
return toHexString!(LetterCase.lower)(hash.finish());

Which doesn't work, so used the temp string to test it.

Now I'm using:
return toHexString!(LetterCase.lower)(hash.finish()).dup();

Kinda weird.  But works.  Thank you!

-Andy


Re: md5 return toHexString

2015-04-24 Thread tcak via Digitalmars-d-learn

On Friday, 24 April 2015 at 17:50:03 UTC, AndyC wrote:

Hi All, I cannot seem to understand whats wrong with this:

// main.d
import std.stdio;
import std.digest.md;
import std.file;


string md5sum(const string fname)
{
MD5 hash;

File f = File(fname, "rb");
foreach( ubyte[] buf; f.byChunk(4096))
{
hash.put(buf);
}

string s = toHexString!(LetterCase.lower)(hash.finish());
writeln(s);   //This is correct
return s;
}

void main()
{
string crc = md5sum("main.d");
writeln(crc);  //This is garbage
}


The writeln in md5sum prints correctly, but the "return s" 
seems to mess it up?  What's going on?


Thanks for you time,

-Andy


Just do that "return s.dup()". Then it works for me. That's 
probably due to the fact that s is in stack. But I am not sure 
how "toHexString" works.


md5 return toHexString

2015-04-24 Thread AndyC via Digitalmars-d-learn

Hi All, I cannot seem to understand whats wrong with this:

// main.d
import std.stdio;
import std.digest.md;
import std.file;


string md5sum(const string fname)
{
MD5 hash;

File f = File(fname, "rb");
foreach( ubyte[] buf; f.byChunk(4096))
{
hash.put(buf);
}

string s = toHexString!(LetterCase.lower)(hash.finish());
writeln(s);   //This is correct
return s;
}

void main()
{
string crc = md5sum("main.d");
writeln(crc);  //This is garbage
}


The writeln in md5sum prints correctly, but the "return s" seems 
to mess it up?  What's going on?


Thanks for you time,

-Andy


Re: No line numbers in compiler error messages

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/24/15 1:20 PM, John Nixon wrote:

I am using dmd v2.067.0 on Mac OSX with Terminal and I found the lack of
line numbers surprising.
Is there something simple I am doing wrong? Do any of the switches on
the command line do this?


It does post line numbers. Please post source and compile line that 
causes this, and also result so it may be duplicated.


-Steve


No line numbers in compiler error messages

2015-04-24 Thread John Nixon via Digitalmars-d-learn
I am using dmd v2.067.0 on Mac OSX with Terminal and I found the 
lack of line numbers surprising.
Is there something simple I am doing wrong? Do any of the 
switches on the command line do this?


BTW I only found out about D a couple of weeks back. It seems to 
be very impressive!


John Nixon


__gshared static

2015-04-24 Thread via Digitalmars-d-learn

Hi!

I just stumbled across what seems like a misunderstanding on my 
side about these keywords. Can someone help clarify these for me?


```
__gshared static int foo;
__gshared int foo;
```

What are the storage and semantic differences between those two, 
if any?


Cheers,
-M


Re: How to output ascii character using terminal.d

2015-04-24 Thread Adam D. Ruppe via Digitalmars-d-learn
Try terminal.writef("%s", cast(char) your_ascii_character); it 
should work.


How to output ascii character using terminal.d

2015-04-24 Thread Paul via Digitalmars-d-learn
How do I output a single ascii character specified numerically, 
via terminal.d's writef() function which expects a string? Bound 
to be something obvious but I just can't see it atm!


Paul


Re: Fibers and async io stuff for beginners

2015-04-24 Thread Chris via Digitalmars-d-learn

On Friday, 24 April 2015 at 12:38:39 UTC, Jens Bauer wrote:

On Friday, 24 April 2015 at 09:15:21 UTC, Chris wrote:


I was more thinking of the audio thread. But the audio is 
probably better off in a separate thread.


I think you could do this too.
In fact, this is very similar to how the audio from a MOD file 
is decoded.
(I only mentioned an interrupt, because I'm used to putting 
audio in interrupts, since I work very close to the hardware; 
meaning that interrupts will normally be much more efficient)


I might give it a shot.


Re: function ref param vs pointer param

2015-04-24 Thread ref2401 via Digitalmars-d-learn

Thank you


Re: function ref param vs pointer param

2015-04-24 Thread Ali Çehreli via Digitalmars-d-learn

On 04/24/2015 06:23 AM, ref2401 wrote:

> What advantages do ref params give over pointer params?

Another difference is that a ref parameter is not null and what is 
referred to is not an rvalue.


However, it is possible to break that expectation if a pointer is 
dereferenced and passed to a ref-taking function but then the actual 
object is gone before the reference is used.


Ali



Re: function ref param vs pointer param

2015-04-24 Thread bearophile via Digitalmars-d-learn

On Friday, 24 April 2015 at 13:39:35 UTC, ref2401 wrote:

processPointer(&ms);
I think doing this way is more descriptive.
Now all readers know that ms might be changed inside the 
function.


C# avoids that problem requiring (in most cases) the usage of 
"ref" at the calling point too. But this idea was refused for D 
(also because it goes against UFCS chains).


Bye,
bearophile


Re: function ref param vs pointer param

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/24/15 9:23 AM, ref2401 wrote:

What advantages do ref params give over pointer params?

struct MyStruct {
 string str;

 this(string str) { this.str = str; }
}

void processRef(ref MyStruct ms) {
 writeln("processRef: ", ms);
}

void processPointer(MyStruct* ms) {
 writeln("processPointer: ", *ms);
}

void main(string[] args) {
 auto ms = MyStruct("the ultimate answer to everythin is the number
42");

 processRef(ms);
 processPointer(&ms);
}


A ref param is somewhat safer, because you cannot do pointer arithmetic 
on it. A ref will ALWAYS point at the same memory location, because it 
cannot be rebound.


The compiler can also take advantage of the characteristics of ref, as 
it does with the -dip25 switch.


-Steve


Re: function ref param vs pointer param

2015-04-24 Thread ref2401 via Digitalmars-d-learn

processPointer(&ms);
I think doing this way is more descriptive.
Now all readers know that ms might be changed inside the function.


Re: function ref param vs pointer param

2015-04-24 Thread bearophile via Digitalmars-d-learn

ref2401:


void processRef(ref MyStruct ms) {
writeln("processRef: ", ms);
}

void processPointer(MyStruct* ms) {
writeln("processPointer: ", *ms);


ref params don't need the "*" every time you use them inside the 
function, and don't need the "&" when you call the function.


Bye,
bearophile


function ref param vs pointer param

2015-04-24 Thread ref2401 via Digitalmars-d-learn

What advantages do ref params give over pointer params?

struct MyStruct {
string str;

this(string str) { this.str = str; }
}

void processRef(ref MyStruct ms) {
writeln("processRef: ", ms);
}

void processPointer(MyStruct* ms) {
writeln("processPointer: ", *ms);
}

void main(string[] args) {
	auto ms = MyStruct("the ultimate answer to everythin is the 
number 42");


processRef(ms);
processPointer(&ms);
}


Re: Startup files for STM32F4xx

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn

On Friday, 24 April 2015 at 07:34:55 UTC, tom wrote:

would something like a STM32 NUCLEO-F401RE work?


I forgot to give you a proper answer on this one: I think it 
should work, as it's a STM32F401 microcontroller.


-So basically you get a 'bare metal' setup with no drivers.
However, as you know already, you can use STM's drivers, because 
D works quite well with C, so you have a fairly good starting 
point.


I hope to add more devices later on, and I also hope to add a few 
convenience libraries and perhaps some runtime for bare-metal.


I do have some additional files, which I didn't want to put in 
the STM32F4xx repository, since they're not directly D-related. 
They include a few linker-scripts and a Makefile (but the 
Makefile will probably not be to your liking, as it assumes a lot 
of things and is not Windows-compatible).


The current linker-scripts can be downloaded here:
d.gpio.dk/dl/linker-scripts.zip

You may want to cripple the following slightly:

__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} >flash
__exidx_end = .;


by changing it to:

__exidx_start = .;
/*  .ARM.exidx :*/
/DISCARD/ :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} >flash
__exidx_end = .;

Both Mike and Timo are the true pioneers here; they have done 
very valuable hard work. Johannes made it possible to use the 
weak, alias and section attributes, so we have the most important 
functionality for microcontroller support.


Note: If anyone wants read/write access, please let me know; send 
me an email to the domain name, where you replace the first dot 
with @


Re: Startup files for STM32F4xx

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/23/15 11:30 AM, Jens Bauer wrote:

On Thursday, 23 April 2015 at 12:14:59 UTC, Steven Schveighoffer wrote:



You can't use something like this?
http://www.floodgap.com/software/tenfourfox/


Wow, I thought they stopped making builds at v20! -I'm pretty sure they
said on the Web-site that v20 was the last build. But this is great,
thank you for letting me know. I've downloaded it (though a bit slow) it
appears to work.


No problem :) I was a little surprised firefox proper was not continuing 
to support power pc Mac, but I guess as they upgrade to use new OS UI 
features, it would drift the codebase apart.



In my attempt to make a read-access on my git repositories, I upgraded
both Gitolite and git to latest versions; but I still didn't succeed in
making it possible to clone without a SSH key.


I was hoping that github access would be possible now with a more modern 
browser, no?



The most important thing, though, is that D-programmers now have a
starting point for the STM32F4xx. It should be easy to adapt the same
sources to other MCUs. I'm planning on adding support for some of the
LPC microcontrollers myself.


I want to say, I remember Mike's talk last year, and having worked with 
ST7 micros (small ones, not even close to being supportable by D), I 
thought it was the coolest thing. I am very excited to see a possibility 
of using D for embedded programming. This really could be a niche win for D!


-Steve


Re: Startup files for STM32F4xx

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn

On Friday, 24 April 2015 at 07:34:55 UTC, tom wrote:

On Thursday, 23 April 2015 at 15:30:18 UTC, Jens Bauer wrote:
The most important thing, though, is that D-programmers now 
have a starting point for the STM32F4xx. It should be easy to 
adapt the same sources to other MCUs. I'm planning on adding 
support for some of the LPC microcontrollers myself.


this looks pretty cool.
i would love to try this out (could't figure out how to clone 
it though)


I've made a tar.gz archive and placed it here:
d.gpio.dk/dl/STM32F4xx.tar.gz


which board do you use?


I'm using STM32F407 Discovery board and a bunch of bare-metal 
boards I designed (most of them are on breadboards)



what devices work?


Initially, I've only made files for the F4 family:
STM32F401, STM32F405, STM32F407, STM32F411, STM32F415, STM32F417, 
STM32F427, STM32F429, STM32F437 and STM32F439.


I only have STM32F407, STM32F427 and STM32F429 myself though, so 
I will not be able to test on the other devices in this family.



would something like a STM32 NUCLEO-F401RE work?


You'll need to modify the exception vector table, which should be 
quite straightfoward (but may take some time, because it's a 
line-by-line job).


But before you start doing a lot of manual work, look at the 
template files and the generator script. The generator script is 
actually dong some of the hard work for you. Just list the 
exception vectors in the correct order in a file called 
stm32f103.txt for instance, then add this file to the 
bin/generate and run that scipt.


Re: Fibers and async io stuff for beginners

2015-04-24 Thread Jens Bauer via Digitalmars-d-learn

On Friday, 24 April 2015 at 09:15:21 UTC, Chris wrote:


I was more thinking of the audio thread. But the audio is 
probably better off in a separate thread.


I think you could do this too.
In fact, this is very similar to how the audio from a MOD file is 
decoded.
(I only mentioned an interrupt, because I'm used to putting audio 
in interrupts, since I work very close to the hardware; meaning 
that interrupts will normally be much more efficient)


Re: Download DDMD?

2015-04-24 Thread Joakim via Digitalmars-d-learn
On Wednesday, 22 April 2015 at 07:57:40 UTC, Jeremiah DeHaan 
wrote:
Just curious, but I was wondering if there was a 2.067 DDMD 
available for download somewhere for Windows. If not, then are 
there any special build instructions I need to build it? I kind 
of just want to try a couple of things, so I would rather I not 
have to build it if I can avoid it.


No, just build dmd from source as you normally would, but add the 
target ddmd instead.  They are supposedly going to try to get the 
next 2.068 release to use ddmd, and want to get the next release 
out sooner, so you may not have to wait long for an official ddmd 
release.


Re: Fibers and async io stuff for beginners

2015-04-24 Thread Chris via Digitalmars-d-learn

On Thursday, 23 April 2015 at 22:26:28 UTC, Jens Bauer wrote:

On Thursday, 23 April 2015 at 19:24:31 UTC, Chris wrote:

On Thursday, 23 April 2015 at 16:57:30 UTC, Jens Bauer wrote:

3: Audio mixing and playback (eg. a MOD player for instance).
5: Queueing up a bunch of different jobs;


At the moment I'm using threads to implement a speech 
synthesizer. It waits for input, synthesizes it, and then 
"speaks" in a separate thread. If new input comes, the 
speaking thread is stopped. I wonder, if fibers would be a 
viable alternative to threads (after all audio playback was 
mentioned in the list above).


I'll try and give you some (perhaps useless) input... :)

I think there are a number of good possibilities for spreading 
out the jobs.
First thought is to split every job on spaces; eg. every word 
is a separate job, some words may be possible to "recycle" 
either fully or partly, depending on how they're pronounced in 
the particular context.

I cannot give any conclusions, but I do see that ...
Using multiple CPU cores with each their own Fiber would 
probably be the most optimal solution. Each Fiber could perhaps 
synthesize a word at a time.
-But I do not know if you're able to control which core your 
Fiber is running on.


That would of course only generate the data (faster than 
real-time on most systems).
An audio frame-buffer interrupt could 'pull' the data, when 
necessary. Such an interrupt could also mix multiple voices 
(having different/variable volume and panning) if needed (here 
I'm thinking of 'speaking' the conversations in a chat-room).


I was more thinking of the audio thread. But the audio is 
probably better off in a separate thread.


Re: Startup files for STM32F4xx

2015-04-24 Thread tom via Digitalmars-d-learn

On Thursday, 23 April 2015 at 15:30:18 UTC, Jens Bauer wrote:
The most important thing, though, is that D-programmers now 
have a starting point for the STM32F4xx. It should be easy to 
adapt the same sources to other MCUs. I'm planning on adding 
support for some of the LPC microcontrollers myself.


this looks pretty cool.
i would love to try this out (could't figure out how to clone it 
though)

which board do you use?

what devices work?
would something like a STM32 NUCLEO-F401RE work?