serialport 0.5.4 → 0.5.5
raw patch · 5 files changed
+33/−33 lines, 5 filesdep ~Win32dep ~basedep ~bytestring
Dependency ranges changed: Win32, base, bytestring, unix
Files
- CHANGELOG.md +6/−0
- README.md +1/−1
- System/Hardware/Serialport/Posix.hsc +18/−24
- System/Win32/Comm.hsc +2/−2
- serialport.cabal +6/−6
CHANGELOG.md view
@@ -1,3 +1,9 @@+0.5.5 (1/15/2024)+=================+* Fix runtime error on Windows [6](https://github.com/standardsemiconductor/serialport/pull/6)+* Deprecate String `fdRead` [9](https://github.com/standardsemiconductor/serialport/pull/9)+* Update to unix-2.8 [8](https://github.com/standardsemiconductor/serialport/pull/8)+ 0.5.4 (12/02/2022) ================== * Update package dependency constraints
README.md view
@@ -1,6 +1,6 @@ # Serialport -+[](https://github.com/standardsemiconductor/serialport/actions/workflows/haskell.yml) [![Hackage][hackage-badge]][hackage] [![Hackage Dependencies][hackage-deps-badge]][hackage-deps]
System/Hardware/Serialport/Posix.hsc view
@@ -1,28 +1,24 @@ {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE LambdaCase #-}-{-# OPTIONS_HADDOCK hide #-}+{-# OPTIONS_HADDOCK hide #-} module System.Hardware.Serialport.Posix where +import qualified Control.Exception as Ex+import Data.Bits+import qualified Data.ByteString.Char8 as B+import Data.Either+import Data.Typeable+import Foreign (Ptr, nullPtr, castPtr, alloca, peek, with)+import Foreign.C import GHC.IO.Handle import GHC.IO.Encoding-+import System.Hardware.Serialport.Types import System.Posix.IO-import System.Posix.Types (Fd, ByteCount)+import qualified System.Posix.IO.ByteString as BIO+import System.Posix.Types (Fd) import System.Posix.Terminal -import Foreign (Ptr, nullPtr, castPtr, alloca, peek, with)-import Foreign.C--import Data.Typeable-import Data.Bits--import qualified Data.ByteString.Char8 as B-import qualified Control.Exception as Ex--import System.Hardware.Serialport.Types-- data SerialPort = SerialPort { fd :: Fd , portSettings :: SerialPortSettings@@ -39,11 +35,12 @@ -- |Open and configure a serial port-openSerial :: FilePath -- ^ Serial port, such as @\/dev\/ttyS0@ or @\/dev\/ttyUSB0@- -> SerialPortSettings- -> IO SerialPort+openSerial+ :: FilePath -- ^ Serial port, such as @\/dev\/ttyS0@ or @\/dev\/ttyUSB0@+ -> SerialPortSettings+ -> IO SerialPort openSerial dev settings = do- fd' <- openFd dev ReadWrite Nothing defaultFileFlags { noctty = True, nonBlock = True }+ fd' <- openFd dev ReadWrite defaultFileFlags { noctty = True, nonBlock = True } setTIOCEXCL fd' setFdOption fd' NonBlockingRead False let serial_port = SerialPort fd' defaultSerialSettings@@ -67,13 +64,10 @@ -- |Receive bytes, given the maximum number recv :: SerialPort -> Int -> IO B.ByteString recv port n = do- result <- withEncoding char8 $ Ex.try $ fdRead (fd port) count :: IO (Either IOError (String, ByteCount))- return $ case result of- Right (str, _) -> B.pack str- Left _ -> B.empty+ result <- withEncoding char8 $ Ex.try $ BIO.fdRead (fd port) count :: IO (Either IOError B.ByteString)+ return $ fromRight B.empty result where count = fromIntegral n- -- |Send bytes send
System/Win32/Comm.hsc view
@@ -37,7 +37,7 @@ instance Storable SerialPortSettings where sizeOf _ = #{size DCB}- alignment = sizeOf+ alignment _ = 16 poke buf settings = do #{poke DCB, DCBlength} buf (sizeOf settings) #{poke DCB, BaudRate} buf (fromIntegral (commSpeedToBaudRate (commSpeed settings)) :: DWORD)@@ -138,7 +138,7 @@ instance Storable COMMTIMEOUTS where sizeOf _ = #{size COMMTIMEOUTS}- alignment = sizeOf+ alignment _ = 16 poke buf ct = do #{poke COMMTIMEOUTS, ReadIntervalTimeout} buf (readIntervalTimeout ct) #{poke COMMTIMEOUTS, ReadTotalTimeoutMultiplier} buf ( readTotalTimeoutMultiplier ct)
serialport.cabal view
@@ -1,11 +1,11 @@ Name: serialport-Version: 0.5.4+Version: 0.5.5 Cabal-Version: >= 1.10 Build-Type: Simple license: BSD3 license-file: LICENSE copyright: (c) 2009-2011 Joris Putcuyps,- (c) 2020-2022 David Cox+ (c) 2020-2024 David Cox author: Joris Putcuyps, David Cox maintainer: David Cox <standard.semiconductor@gmail.com> homepage: https://github.com/standardsemiconductor/serialport@@ -24,16 +24,16 @@ Library Exposed-Modules: System.Hardware.Serialport Other-Modules: System.Hardware.Serialport.Types- Build-Depends: base >= 4.12 && < 4.17, - bytestring >= 0.11 && < 0.12+ Build-Depends: base >= 4.12 && < 4.20,+ bytestring >= 0.11 && < 0.13 ghc-options: -Wall -fno-warn-orphans default-language: Haskell2010 if !os(windows)- Build-Depends: unix >= 2.7 && < 2.8+ Build-Depends: unix >= 2.8 && < 2.9 Other-Modules: System.Hardware.Serialport.Posix else- Build-Depends: Win32 >= 2.11 && < 2.14+ Build-Depends: Win32 >= 2.11 && < 2.15 Other-Modules: System.Hardware.Serialport.Windows System.Win32.Comm