|
I aim to build a network system like router or firewall based on customized embedded Linux. about the memory and stack, I will use embedded appliance like ARM boards or Atom not a simple Micro-controller or processor. which lang. you advice me to use C or C++? . I will use YOCTO Project to help me do that.
I built a similar network system.it was a network IDS but, it was based on xPC Target Kernel. Now, I wish to use an Embedded Linux. the system must do the basic task, so no many options. I have an experience in C and C++ but under DOS not Linux. C++ has the many options make the system design is easier but I fare the compatibility if I used it in embedded Linux. So any advice?
|
|
|
|
|
Abdullah A._Mohamed wrote: C++ has the many options make the system design is easier but I fare the compatibility if I used it in embedded Linux. So any advice?
I bet on C++ : Linux usually provides g++ that is a very good C++ compiler.
By the way, could you please delete your duplicate post?
|
|
|
|
|
CPallini wrote: By the way, could you please delete your duplicate post?
It's not just a duplicate post - he's created two accounts as well!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Wait, maybe we have a replicant! 
|
|
|
|
|
thank you Pallini, its not a duplicated but I am a new here and I login using my other accounts like face and g+ So, it seems two accounts is made and I put the Q on the two accounts. sorry.
modified 24-Jul-15 1:25am.
|
|
|
|
|
Oh, that is no problem at all, for me.
You are welcome. 
|
|
|
|
|
Abdullah A._Mohamed wrote: I fare the compatibility if I used it in embedded Linux
C++ is used pretty extensively in embedded Linux.
This is more of a matter of preference, you should be able to easily find supporting libraries for both, but I'd imagine that you'd find quite a bit more for C++... so that may be the easiest route.
|
|
|
|
|
Albert Holguin, thank you, I hope that.
|
|
|
|
|
See my response to Carlo's message below.
|
|
|
|
|
Don't know why someone downvoted this, have my upvote.
|
|
|
|
|
Thanks Carlo... probably somebody who doesn't know what they're talking about. I'm actually right in the middle of implementing a bunch of C++ on an ARM processor. Cross-compiling is your friend. 
|
|
|
|
|
I aim to build a network system like router or firewall based on customized embedded Linux. about the memory and stack, I will use embedded appliance like ARM boards or Atom not a simple Micro-controller or processor. which lang. you advice me to use C or C++? . I will use YOCTO Project to help me do that, so any advice?
I built a similar network system.it was a network IDS but, it was based on xPC Target Kernel. Now, I wish to use an Embedded Linux. the system must do the basic task, so no many options. I have an experience in C and C++ but under DOS not Linux. C++ has the many options make the system design is easier but I fare the compatibility if I used it in embedded Linux. So any advice?
|
|
|
|
|
If it's embedded, go with C. Otherwise, just pick whichever one you want.
Jeremy Falcon
|
|
|
|
|
As the title states, I am having problems reading uncompressed avi files in MFC. It works fine on some files and reads different data on some avi files.
Here is the code-
pStream = g_GetAviStream(_T("D:\\Lab_Programs\\Matlab\\output.avi"), &frames, &fWidth, &fHeight, &iFirstFrame, &nPlanes, &fBufSize);
fWidthOffs = fWidth%4;
tempBuff = new BYTE[fWidth*fHeight*nPlanes];
ZeroMemory(tempBuff, sizeof(BYTE)*fWidth*fHeight*nPlanes);
pFrame = AVIStreamGetFrameOpen(pStream, NULL);
bytBuff = new BYTE[fBufSize];
for (i = 0; i < frames; i ++)
{
imgTemp = (BYTE*) AVIStreamGetFrame(pFrame, i);
RtlMoveMemory(&bih.biSize, imgTemp, sizeof(BITMAPINFOHEADER));
RtlMoveMemory(bytBuff, imgTemp+sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*256, bih.biSizeImage);
ind = i*fWidth*fHeight*nPlanes;
for (j = 0; j < fHeight; j ++) {
idxd1 = j*nStimVideoNX;
idxs = (fHeight-1-j) * (fWidth * nPlanes + fWidthOffs);
for (k = 0; k < fWidth; k ++) {
datain = bytBuff[idxs + k*nPlanes];
tempBuff[idxd1+k] = datain;
}
}
}
After doing this, I am writing tempBuff to a text file to view the contents in maltab and imshow it. If you play the video, you will see two black squares inside the frame, but when I check the text file for frame 3, I only see one black square. Here is the link[^] for a sample file that I am trying to read.
PKNT
|
|
|
|
|
Are you certain that all of your test files have a 256-colour palette? See the BITMAPINFOHEADER structure[^] for details about other possibilities.
Note also that the height, width, and number of planes are encoded in the header. Ensure that these are as expected before decoding!
Lastly, the BITMAPINFOHEADER contains its size in the first element. Use this either as a "sanity check" or instead of sizeof(BITMAPINFOHEADER).
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
For the file I attached in my first post, AVIFileInfo is returning the following data-
avi_info {dwMaxBytesPerSec=0 dwFlags=0 dwCaps=3 ...} _AVIFILEINFOA
dwMaxBytesPerSec 0 unsigned long
dwFlags 0 unsigned long
dwCaps 3 unsigned long
dwStreams 1 unsigned long
dwSuggestedBufferSize 2296 unsigned long
dwWidth 26 unsigned long
dwHeight 82 unsigned long
dwScale 33333 unsigned long
dwRate 1000000 unsigned long
dwLength 30 unsigned long
dwEditCount 0 unsigned long
szFileType 0x0068e930 "AVI Default File Handler" char [64]
When I write the frame to a text file after
imgTemp = (BYTE*) AVIStreamGetFrame(pFrame, i);
I see the correct header of 1064 bytes, but the image data doesn't have two black squares that I am supposed to see (for example from frame 3), but only one black square.
Any ideas?
PKNT
|
|
|
|
|
If you are writing the data to a text file in Windows, it is quite possible that you will see garbage. You must write the file as a binary file (e.g. fopen(file, "wb")).
I can't actually read your sample file (I don't have access to your OneDrive account), so I can't verify this myself.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
I guess I found the problem. It was the way Matlab is writing the avi files. By default, for uncompressed gray scale avi files it uses 64 level color map and indicies data to it. Now the problem is resolved.
PKNT
|
|
|
|
|
I am trying to rebuild small data base to improve on my terrible knowledge of pointers.
The array is pretty simple integers representing ASCII code , I do the conversion by casting the int or char to LCD print function for display. Works fine with one problem - one of the int in the array is a REAL number ( 0 thru 9) , not just ASCII representation of a number.
For illustration - the ints are 32 65 73 7 73
The "problem " the index #3 does not read just 7 , but 773.
And the array sizeof is also 3 , and it should be 4.
Majority of the code is just for debug.
I can change the real numbers to ASCII representation but would like to know why is this behaving this way.
Appreciate your help.
Vaclav
<pre><pre
int *pCarrier[sizeof(iRecordIndex)];
for (i = 0; i != sizeof(iRecordIndex); i++)
{
pCarrier[i] = &iRecord[i]; // assign data to pointer
lcd_i2c.setCursor(0, 0);
lcd_i2c.print("Index " );
lcd_i2c.print(i);
lcd_i2c.setCursor(0, 1);
lcd_i2c.print((char) iRecord[i] );
lcd_i2c.setCursor(0, 2);
lcd_i2c.print(iRecord[i] );
lcd_i2c.print(" ");
lcd_i2c.print(*pCarrier[i] );
delay(DELAY);
}
lcd_i2c.clear();
lcd_i2c.print("Database " );
lcd_i2c.setCursor(0, 1);
for (i = 0; i != sizeof(iRecordIndex)+ 1 ; i++)
{
lcd_i2c.print((int)*pCarrier[i] );
delay(DELAY);
}
pre></pre>
|
|
|
|
|
How is iRecord declared and initialized?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Why are you using double dereferencing? It would be much easier to code (and certainly to understand) by using arrays of integers rather than pointers. Something like:
int pCarrier[sizeof(iRecordIndex)]; for (i = 0; i < sizeof(iRecordIndex); i++)
{
pCarrier[i] = iRecord[i];
Or better still just use the elements of the original array, since, presumably, it is a simple aray of integers.
|
|
|
|
|
I have modified the 3 position in the int array to ASCII representation and it worked.
I do not understand why it does not work with int 0 thru 9 in 3rd position.
I have included the database read and that is totally bogus when it fails.
I still do not understand what the sizeof(iRecordIndex) is telling me.
Modifying the iRecordIndex ( adding to it ) does not have any effects.
The record has been initialized - this is first time I am using it and it contains 5 ints and rest of it is all zeroes.
The iRecordIndex is 4 during this test.
PS I had the end test in for loop wrong, but the 3rd index value was still printing wrong on LCD.
<pre lang="c++"></pre>
//iRecord[iRecordIndex]
//iRecordIndex += 3;
int iField[32] = {}; // will need to reinitialize
int *pCarrier[sizeof(iRecordIndex)]; // ponter to field
for (i = 0; i != sizeof(iRecordIndex)+ 1 ; i++)
{
pCarrier[i] = &iRecord[i]; // assign data to pointer
lcd_i2c.setCursor(0, 0);
lcd_i2c.print("Index " );
lcd_i2c.print(i);
//lcd_i2c.print(pCarrier );
lcd_i2c.setCursor(0, 1);
lcd_i2c.print((char) iRecord[i] );
lcd_i2c.setCursor(0, 2);
lcd_i2c.print(iRecord[i] );
lcd_i2c.print(" ");
lcd_i2c.print(*pCarrier[i] );
delay(2*DELAY);
}
lcd_i2c.clear();
lcd_i2c.print("Database " );
lcd_i2c.setCursor(0, 1);
for (i = 0; i != sizeof(iRecordIndex) + 1 ; i++)
{
lcd_i2c.print((int)*pCarrier[i] );
delay(DELAY);
}
|
|
|
|
|
Vaclav_Sal wrote: I still do not understand what the sizeof(iRecordIndex) is telling me.
You have not told us how iRecordIndex is declared and initialized.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Sorry.
Both iRecord and iRecordIndex are declared as int and as class variables and initialized in the start of this loop.
The iRecord is reset for next iDatabaseIndex, but I am not that far in checking the code.
(The record needs to be split into several fields, again of variable length).
I wanted to "do pointers" since the database fields length vary and like to save some memory in ARM processor.
for (iDatabaseIndex = 0; iDatabaseIndex < MAX_DATABASE; iDatabaseIndex++)
{
iRecordIndex = 0;
iRecord[32] = {};
....
|
|
|
|