standardsemiconductor / serialport

Cross platform Haskell library for using the serial port
https://hackage.haskell.org/package/serialport
Other
4 stars 8 forks source link

Runtime error on Windows #5

Closed karutten closed 8 months ago

karutten commented 1 year ago

When i open a device, i get this error: allocaBytesAligned: invalid argument (alignment (=20) must be a power of two!) Using GHC 9.2.5 on Windows.

I was able to fix this by changing the alignment of two Storable instances, that are currently invalid: https://github.com/standardsemiconductor/serialport/blob/bbebf5f0c3c7b0ee0cd89279ec3170b4d47d59ac/System/Win32/Comm.hsc#L40 https://github.com/standardsemiconductor/serialport/blob/bbebf5f0c3c7b0ee0cd89279ec3170b4d47d59ac/System/Win32/Comm.hsc#L141

I used 16 to be sure, but 8 or even 4 is probably enough. A proper solution would probably be to reuse the alignment of one of the fields.

dopamane commented 1 year ago

Thanks for bringing this to my attention! When I can find free time I will address this. Feel free to open a PR as well.