[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeutils/okteta/kasten/gui
From:       Friedrich W. H. Kossebau <kossebau () kde ! org>
Date:       2010-01-30 1:28:59
Message-ID: 1264814939.120928.31901.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1082221 by kossebau:

added: config to set the address size (8,16,32) for the Intel Hex encoder (TBD: check \
if address size matches the data to encode)

 M  +7 -1      CMakeLists.txt  
 M  +2 -0      io/bytearraystreamencoderconfigeditorfactoryfactory.cpp  
 M  +31 -12    io/streamencoder/ihex/bytearrayihexstreamencoder.cpp  
 M  +27 -0     io/streamencoder/ihex/bytearrayihexstreamencoder.h  
 A             io/streamencoder/ihex/bytearrayihexstreamencoderconfigeditor.cpp   \
[License: LGPL]  A             \
io/streamencoder/ihex/bytearrayihexstreamencoderconfigeditor.h   [License: LGPL]  A   \
io/streamencoder/ihex/bytearrayihexstreamencoderconfigeditorfactory.cpp   [License: \
LGPL]  A             \
io/streamencoder/ihex/bytearrayihexstreamencoderconfigeditorfactory.h   [License: \
LGPL]


--- trunk/KDE/kdeutils/okteta/kasten/gui/CMakeLists.txt #1082220:1082221
@@ -62,6 +62,12 @@
   io/streamencoder/srec/bytearraysrecstreamencoder.cpp
 )
 
+set( okteta_ihex_streamencoder_SRCS
+  io/streamencoder/ihex/bytearrayihexstreamencoderconfigeditor.cpp
+  io/streamencoder/ihex/bytearrayihexstreamencoderconfigeditorfactory.cpp
+  io/streamencoder/ihex/bytearrayihexstreamencoder.cpp
+)
+
 set( okteta_viewtext_streamencoder_SRCS
   io/streamencoder/viewtext/abstractcolumntextrenderer.cpp
   io/streamencoder/viewtext/offsetcolumntextrenderer.cpp
@@ -83,7 +89,7 @@
   io/streamencoder/base85/bytearraybase85streamencoder.cpp
   ${okteta_uuencoding_streamencoder_SRCS}
   ${okteta_srec_streamencoder_SRCS}
-  io/streamencoder/ihex/bytearrayihexstreamencoder.cpp
+  ${okteta_ihex_streamencoder_SRCS}
   ${okteta_sourcecode_streamencoder_SRCS}
   ${okteta_viewtext_streamencoder_SRCS}
   io/bytearraystreamencoderfactory.cpp
--- trunk/KDE/kdeutils/okteta/kasten/gui/io/bytearraystreamencoderconfigeditorfactoryfactory.cpp \
#1082220:1082221 @@ -28,6 +28,7 @@
 #include "streamencoder/base32/bytearraybase32streamencoderconfigeditorfactory.h"
 #include "streamencoder/uuencoding/bytearrayuuencodingstreamencoderconfigeditorfactory.h"
  #include "streamencoder/srec/bytearraysrecstreamencoderconfigeditorfactory.h"
+#include "streamencoder/ihex/bytearrayihexstreamencoderconfigeditorfactory.h"
 //// NEWBYTEARRAYSTREAMENCODERCONFIGEDITORFACTORY(start)
 //// Here add the name of your header file of your streamencoder,
 //// e.g.
@@ -49,6 +50,7 @@
         << new ByteArrayValuesStreamEncoderConfigEditorFactory()
         << new ByteArrayBase32StreamEncoderConfigEditorFactory()
         << new ByteArraySRecStreamEncoderConfigEditorFactory()
+        << new ByteArrayIHexStreamEncoderConfigEditorFactory()
         << new ByteArrayUuencodingStreamEncoderConfigEditorFactory();
 //// NEWBYTEARRAYSTREAMENCODERCONFIGEDITORFACTORY(start)
 //// Here add the creation of an object of your streamencoder class and add it to \
                the list,
--- trunk/KDE/kdeutils/okteta/kasten/gui/io/streamencoder/ihex/bytearrayihexstreamencoder.cpp \
#1082220:1082221 @@ -37,6 +37,10 @@
 namespace Kasten
 {
 
+IHexStreamEncoderSettings::IHexStreamEncoderSettings()
+ : addressSizeId( Bits32Id )
+{}
+
 static const int outputLineLength = 78;
 static const int maxOutputBytesPerLine = outputLineLength;
 
@@ -102,10 +106,9 @@
     textStream << checksum << '\n';
 }
 
-#if 0
-static
+static inline
 void streamExtendedSegmentAddress( QTextStream& textStream, unsigned char* line,
-                                   quint16 upperSegmentBaseAddress = 0 )
+                                   quint16 upperSegmentBaseAddress )
 {
     static const int nullAddress = 0;
     static const int upperSegmentBaseAddressSize = 2;
@@ -118,9 +121,8 @@
 
     streamLine( textStream, line );
 }
-#endif
 
-static
+static inline
 void streamExtendedLinearAddress( QTextStream& textStream, unsigned char* line,
                                   quint16 upperLinearBaseAddress )
 {
@@ -136,7 +138,7 @@
     streamLine( textStream, line );
 }
 
-static
+static inline
 void streamEndOfFile( QTextStream& textStream, unsigned char* line,
                       quint16 startAddress = 0 )
 {
@@ -149,8 +151,9 @@
     streamLine( textStream, line );
 }
 
+
 ByteArrayIHexStreamEncoder::ByteArrayIHexStreamEncoder()
-  : AbstractByteArrayStreamEncoder( i18nc("name of the encoding target","Intel \
Hex"), QString::fromLatin1("text/plain") ) +  : AbstractByteArrayStreamEncoder( \
i18nc("name of the encoding target","Intel Hex..."), \
QString::fromLatin1("text/plain") )  {}
 
 
@@ -167,7 +170,7 @@
     QTextStream textStream( device );
 
     // prepare
-    static const int maxDataPerLineCount = 32;
+    static const int maxDataPerLineCount = 255;
     static const int maxLineLength =
         maxDataPerLineCount + byteCountLineSize + addressLineSize + \
recordTypeLineSize;  
@@ -188,8 +191,16 @@
                             qMin(firstDataEnd,nextUpperAddressChangeDataEnd) );
 
     // data
-    const quint16 upperAddress = (range.start() >> 16);
-    streamExtendedLinearAddress( textStream, line, upperAddress );
+    if( mSettings.addressSizeId == IHexStreamEncoderSettings::Bits32Id )
+    {
+        const quint16 upperLinearBaseAddress = (range.start() >> 16);
+        streamExtendedLinearAddress( textStream, line, upperLinearBaseAddress );
+    }
+    else if( mSettings.addressSizeId == IHexStreamEncoderSettings::Bits16Id )
+    {
+        const quint16 upperSegmentBaseAddress = (range.start() >> 4) & 0xF000;
+        streamExtendedSegmentAddress( textStream, line, upperSegmentBaseAddress );
+    }
     Okteta::Address i = range.start();
     while( i <= range.end() )
     {
@@ -210,8 +221,16 @@
 
             if( d == nextUpperAddressChangeDataEnd )
             {
-                const quint16 upperAddress = (i >> 16);
-                streamExtendedLinearAddress( textStream, line, upperAddress );
+                if( mSettings.addressSizeId == IHexStreamEncoderSettings::Bits32Id )
+                {
+                    const quint16 upperLinearBaseAddress = (i >> 16);
+                    streamExtendedLinearAddress( textStream, line, \
upperLinearBaseAddress ); +                }
+                else if( mSettings.addressSizeId == \
IHexStreamEncoderSettings::Bits16Id ) +                {
+                    const quint16 upperSegmentBaseAddress = (i >> 4) & 0xF000;
+                    streamExtendedSegmentAddress( textStream, line, \
upperSegmentBaseAddress ); +                }
             }
             nextUpperAddressChangeDataEnd = 0x10000 - (i & 0xFFFF);
             nextDataEnd = qMin( dataPerLineCount,
--- trunk/KDE/kdeutils/okteta/kasten/gui/io/streamencoder/ihex/bytearrayihexstreamencoder.h \
#1082220:1082221 @@ -34,6 +34,18 @@
 namespace Kasten
 {
 
+class IHexStreamEncoderSettings
+{
+  public:
+    enum AddressSizeId { Bits32Id = 0, Bits16Id = 1, Bits8Id = 2 };
+
+  public:
+    IHexStreamEncoderSettings();
+  public:
+    AddressSizeId addressSizeId;
+};
+
+
 class ByteArrayIHexStreamEncoder : public AbstractByteArrayStreamEncoder
 {
     Q_OBJECT
@@ -42,13 +54,28 @@
     ByteArrayIHexStreamEncoder();
     virtual ~ByteArrayIHexStreamEncoder();
 
+  public:
+    IHexStreamEncoderSettings settings() const;
+    void setSettings( const IHexStreamEncoderSettings& settings );
+
   protected: // AbstractByteArrayStreamEncoder API
     virtual bool encodeDataToStream( QIODevice* device,
                                      const ByteArrayView* byteArrayView,
                                      const Okteta::AbstractByteArrayModel* \
byteArrayModel,  const Okteta::AddressRange& range );
+
+  protected:
+    IHexStreamEncoderSettings mSettings;
 };
 
+
+inline IHexStreamEncoderSettings ByteArrayIHexStreamEncoder::settings() const { \
return mSettings; } +inline void ByteArrayIHexStreamEncoder::setSettings( const \
IHexStreamEncoderSettings& settings ) +{
+    mSettings = settings;
+    emit settingsChanged();
 }
 
+}
+
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic