PPPoS configurations for the lwIP Stack - freertos

I am working on the lwIP stack with the ATSAMV71 microcontroller.
I would like to configure the lwIP stack in PPPoS mode using a TCP/IP connection.
Will you please help me to know,
What is required #define the configurations required to put the lwIP stack into PPPoS mode?

/*
---------------------------------
---------- PPP options ----------
---------------------------------
*/
#define PPP_SUPPORT 1
#define PAP_SUPPORT 1
#define LWIP_DNS 1
/*
---------------------------------
--------- GPRS options ----------
---------------------------------
*/
#define GPRS_DEBUG LWIP_DBG_OFF
#define GPRS_SUPPORT 1
#define GPRS_TYPE 1
#define GPRS_OWNTHREAD 1
#define GPRS_THREAD_NAME "pppos"
#define GPRS_RUNTIME_APN 1
#define GPRS_RUNTIME_PIN 1
#define GPRS_COMMAND_DELAY 500
#define GPRS_ICCID 1
#define GPRS_THREAD_STACKSIZE 512
#define GPRS_THREAD_PRIO 2
#define GPRS_PPPIF_NAME_0 'P'
#define GPRS_PPPIF_NAME_1 '0'

Related

How do I go build a Go GTK 2 app for Windows from Linux? Is there a Docker image?

I am trying to cross-compile a .go file for the GTK binding package Linux => Windows and can't figure it out. Tried going the route of setting up MSYS on Win but it was god-awful.
I looked for a Docker image but there is none.
$ ~/go/src/gui$ GOOS=windows CGO_ENABLED=1 GOARCH= CC=x86_64-w64-mingw32-gcc go build
# github.com/mattn/go-gtk/glib
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from ./glib.go.h:4,
from ../github.com/mattn/go-gtk/glib/glib.go:5:
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
/usr/include/glib-2.0/glib/gmacros.h:241:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gmacros.h:238:47: note: in definition of macro 'G_PASTE_ARGS'
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
^~~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:241:44: note: in expansion of macro 'G_PASTE'
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^~~~~~~
/usr/include/glib-2.0/glib/gtypes.h:423:3: note: in expansion of macro 'G_STATIC_ASSERT'
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
^~~~~~~~~~~~~~~
# github.com/mattn/go-gtk/pango
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/pango-1.0/pango/pango-coverage.h:25,
from /usr/include/pango-1.0/pango/pango-font.h:25,
from /usr/include/pango-1.0/pango/pango-attributes.h:25,
from /usr/include/pango-1.0/pango/pango.h:25,
from ./pango.go.h:7,
from ../github.com/mattn/go-gtk/pango/pango.go:5:
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
/usr/include/glib-2.0/glib/gmacros.h:241:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gmacros.h:238:47: note: in definition of macro 'G_PASTE_ARGS'
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
^~~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:241:44: note: in expansion of macro 'G_PASTE'
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^~~~~~~
/usr/include/glib-2.0/glib/gtypes.h:423:3: note: in expansion of macro 'G_STATIC_ASSERT'
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));```

What does this error mean and how exactly can we fix it because the example tonemelody program works fine?

enter code here
#include "Pitches.h"
// notes in the melody:
int melody[] = {
NOTE_FS4, NOTE_FS4, NOTE_D4, NOTE_B3,0, NOTE_B3,0, NOTE_E4,0, NOTE_E4,0,NOTE_E4, NOTE_GS4, NOTE_GS4 NOTE_A4, NOTE_B4,
NOTE_A4, NOTE_A4, NOTE_A4, NOTE_E4,0, NOTE_CS4,0, NOTE_FS4,0, NOTE_FS4,0, NOTE_FS4, NOTE_E4, NOTE_E4, NOTE_FS4, NOTE_E4,
NOTE_D4, NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3,0, NOTE_B3, NOTE_B3,0, NOTE_CS4, NOTE_CS4,0, NOTE_CS4,0, NOTE_A3,0, NOTE_A3,0, NOTE_F4,0, NOTE_F4,
NOTE_F4, NOTE_E4, NOTE_D4, NOTE_D4, NOTE_D4, NOTE_CS4,0, NOTE_B3,0, NOTE_B3,0, NOTE_B3, NOTE_B3,0,0, NOTE_A4, NOTE_A4, NOTE_A4, NOTE_A4, NOTE_A4, NOTE_A4,
NOTE_A4, NOTE_G4,0, NOTE_FS4,0, NOTE_E4,0, NOTE_A4, NOTE_A4, NOTE_G4, NOTE_G4, NOTE_A4, NOTE_A4,
NOTE_E5, NOTE_FS5, NOTE_FS5, NOTE_E5, NOTE_A4, NOTE_A4, NOTE_E5, NOTE_E5, NOTE_FS5, NOTE_FS5, NOTE_E4, NOTE_F4
};
//note durations: 2 = half note, 4 = quarter note, 8 = eighth note, 12 = twelveth note, :
int noteDurations[] = {
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
12, 8, 8, 8, 4, 8, 8, 8, 8, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 4, 2, 2, 2, 2, 2, 2,
12, 8, 4, 4, 2, 2, 2, 2, 2, 2, 12, 8,
};
void setup() {
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 12; thisNote++) {
// calculate the note duration as 1 second divided by note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / noteDurations[thisNote];
tone(12, melody[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(12);
}
}
void loop() {
// no need to repeat the melody.
}
This is the file included for pitches
/*************************************************
* Public Constants
*************************************************/
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978
As part of an engineering project for school we were asked to make a program that could play a simple song. We have created the code based on the example ToneMelody for the arduino program. we get an error after all of are notes are listed that highlights red on both are music_code file and our pitches.h file. However, on our pitches.h file the error stops at #define Note_AS3 233 it says exit status 1 expected declaration before '}' token. What does this error mean and how exactly can we fix it because the example tonemelody program works fine?
So, there's a number of errors in your posted sketch which would stop it from compiling.
NOTE_A3 is referenced but not defined
On the very first line of the definition of int melody[], there is no comma between NOTE_GS4 and NOTE_A4
On the third line of the definition of int noteDurations[], you are missing a comma between 8 at the end of the line, and the next element
If you correct all three of these, the code should compile just fine. You should, however, receive more than just one error like you describe from the Arduino IDE. I received notably more, which allowed me to at least figure out where each problem was. If you don't see it in the Arduino error box, you should at least see it through the command line output, which will allow you to track these down in the future.

Switch on/off NSLog with a boolean just like CCLog in cocos2d

I have a IS_TESTING boolean flag indicating whether the current build is testing
I want to hide NSLog if IS_TESTING is NO. And it should also support a single string parameter.
This is CCLog from cocos2d:
#define __CCLOGWITHFUNCTION(s, ...) \
NSLog(#"%s : %#",__FUNCTION__,[NSString stringWithFormat:(s), ##__VA_ARGS__])
#define __CCLOG(s, ...) \
NSLog(#"%#",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
#define CCLOG(...) do {} while (0)
#define CCLOGWARN(...) do {} while (0)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG > 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) __CCLOG(__VA_ARGS__)
#endif // COCOS2D_DEBUG
This is what I write:
#define __CCLOG(s, ...) \
NSLog(#"%#",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if IS_TESTING == 0
#define CCLOG(...) do {} while (0)
#elif IS_TESTING == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#endif
use:
CCLOG(#"single string parameter");
CCLOG(#"string format %#", #"parameter");
It runs without crash, but nothing gets printed out.
EDIT:
#define IS_TESTING YES
I have tried
#if IS_TESTING == YES/NO, but still the same as 0/1, nothing gets printed out
Your code works perfectly. But IS_TESTING must be defined before you start the __CCLOG definition stuff.
So, in the .pch file, I wrote:
#define IS_TESTING 1
#define __CCLOG(s, ...) \
NSLog(#"%#",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if IS_TESTING == 0
#define CCLOG(...) do {} while (0)
#elif IS_TESTING == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#endif
And later:
CCLOG(#"%#", #"YES");
Since I have defined IS_TESTING to 1, we log. If I change it to 0, we don't.
As a bonus, I'll show you what I do. It's much simpler. Here it is:
#define MyLog if(0); else NSLog
This makes MyLog equivalent to NSLog. To turn off logging, change 0 to 1.

turn off Cocos2D verbose logging

I just upgraded to cocos 2.1, and am seeing a ridiculous amount of logging to the console, such as:
2013-09-18 23:15:38.120 Notes and Clefs[842:907] cocos2d: deallocing <CCSprite = 0x1182aa0 | Rect = (816.00,640.00,32.00,64.00) | tag = -1 | atlasIndex = -1>
2013-09-18 23:15:38.121 Notes and Clefs[842:907] cocos2d: deallocing <CCSprite = 0x1182600 | Rect = (816.00,128.00,32.00,64.00) | tag = -1 | atlasIndex = -1>
2013-09-18 23:15:38.122 Notes and Clefs[842:907] cocos2d: deallocing <CCArray = 0x1161e00> = ( <CCSprite = 0x1182790 | Rect = (816.00,640.00,32.00,64.00) | tag = -1 | atlasIndex = -1>, )
etc..
From looking at the code, I see:
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
#define CCLOG(...) do {} while (0)
#define CCLOGWARN(...) do {} while (0)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG > 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) __CCLOG(__VA_ARGS__)
#endif // COCOS2D_DEBUG
And I set COCOS2D_DEBUG = 0, but I still get the same verbose logging...
I have Cocos2D in my project as a static library .a file.. Is it possible that this .a already has a macro/constant defined at level 2 or something, and that's why I'm seeing it not make any difference?
Can anyone recommend a way to turn this off?
Yes, when the static library is compiled using the Debug scheme, it'll print all these debug messages out. Try recompiling the static library with the COCOS2D_DEBUG preprocessor macro set to 1.
Why are you adding it as a static .a library though? I just add the cocos2d-ios.xcodeproj to my own project and add libcocos2d.a to Build Phases under Link Binary with Libraries. That way it'll automatically recompile cocos2d whenever a change occurs.

Where is the global memory replay overhead coming from?

Running the code below to write 1 GB in global memory in the NVIDIA Visual Profiler, I get:
- 100% storage efficiency
- 69.4% (128.6 GB/s) DRAM utilization
- 18.3% total replay overhead
- 18.3% global memory replay overhead.
The memory writes are supposed to be coalesced and there is no divergence in the kernel, so the question is where is the global memory replay overhead coming from? I am running this on Ubuntu 13.04, with nvidia-cuda-toolkit version 5.0.35-4ubuntu1.
#include <cuda.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
#include <ctype.h>
#include <sched.h>
#include <assert.h>
static void
HandleError( cudaError_t err, const char *file, int line )
{
if (err != cudaSuccess) {
printf( "%s in %s at line %d\n", cudaGetErrorString(err), file, line);
exit( EXIT_FAILURE );
}
}
#define HANDLE_ERROR(err) (HandleError(err, __FILE__, __LINE__))
// Global memory writes
__global__ void
kernel_write(uint32_t *start, uint32_t entries)
{
uint32_t tid = threadIdx.x + blockIdx.x*blockDim.x;
while (tid < entries) {
start[tid] = tid;
tid += blockDim.x*gridDim.x;
}
}
int main(int argc, char *argv[])
{
uint32_t *gpu_mem; // Memory pointer
uint32_t n_blocks = 256; // Blocks per grid
uint32_t n_threads = 192; // Threads per block
uint32_t n_bytes = 1073741824; // Transfer size (1 GB)
float elapsedTime; // Elapsed write time
// Allocate 1 GB of memory on the device
HANDLE_ERROR( cudaMalloc((void **)&gpu_mem, n_bytes) );
// Create events
cudaEvent_t start, stop;
HANDLE_ERROR( cudaEventCreate(&start) );
HANDLE_ERROR( cudaEventCreate(&stop) );
// Write to global memory
HANDLE_ERROR( cudaEventRecord(start, 0) );
kernel_write<<<n_blocks, n_threads>>>(gpu_mem, n_bytes/4);
HANDLE_ERROR( cudaGetLastError() );
HANDLE_ERROR( cudaEventRecord(stop, 0) );
HANDLE_ERROR( cudaEventSynchronize(stop) );
HANDLE_ERROR( cudaEventElapsedTime(&elapsedTime, start, stop) );
// Report exchange time
printf("#Delay(ms) BW(GB/s)\n");
printf("%10.6f %10.6f\n", elapsedTime, 1e-6*n_bytes/elapsedTime);
// Destroy events
HANDLE_ERROR( cudaEventDestroy(start) );
HANDLE_ERROR( cudaEventDestroy(stop) );
// Free memory
HANDLE_ERROR( cudaFree(gpu_mem) );
return 0;
}
The nvprof profiler and the API profiler are giving different results:
$ nvprof --events gst_request ./app
======== NVPROF is profiling app...
======== Command: app
#Delay(ms) BW(GB/s)
13.345920 80.454690
======== Profiling result:
Invocations Avg Min Max Event Name
Device 0
Kernel: kernel_write(unsigned int*, unsigned int)
1 8388608 8388608 8388608 gst_request
$ nvprof --events global_store_transaction ./app
======== NVPROF is profiling app...
======== Command: app
#Delay(ms) BW(GB/s)
9.469216 113.392892
======== Profiling result:
Invocations Avg Min Max Event Name
Device 0
Kernel: kernel_write(unsigned int*, unsigned int)
1 8257560 8257560 8257560 global_store_transaction
I had the impression that global_store_transation could not be lower than gst_request. What is going on here? I can't ask for both events in the same command, so I had to run the two separate commands. Could this be the problem?
Strangely, the API profiler shows different results with perfect coalescing. Here is the output, I had to run twice to get the proper counters:
$ cat config.txt
inst_issued
inst_executed
gst_request
$ COMPUTE_PROFILE=1 COMPUTE_PROFILE_CSV=1 COMPUTE_PROFILE_LOG=log.csv COMPUTE_PROFILE_CONFIG=config.txt ./app
$ cat log.csv
# CUDA_PROFILE_LOG_VERSION 2.0
# CUDA_DEVICE 0 GeForce GTX 580
# CUDA_CONTEXT 1
# CUDA_PROFILE_CSV 1
# TIMESTAMPFACTOR fffff67eaca946b8
method,gputime,cputime,occupancy,inst_issued,inst_executed,gst_request,gld_request
_Z12kernel_writePjj,7771.776,7806.000,1.000,4737053,3900426,557058,0
$ cat config2.txt
global_store_transaction
$ COMPUTE_PROFILE=1 COMPUTE_PROFILE_CSV=1 COMPUTE_PROFILE_LOG=log2.csv COMPUTE_PROFILE_CONFIG=config2.txt ./app
$ cat log2.csv
# CUDA_PROFILE_LOG_VERSION 2.0
# CUDA_DEVICE 0 GeForce GTX 580
# CUDA_CONTEXT 1
# CUDA_PROFILE_CSV 1
# TIMESTAMPFACTOR fffff67eea92d0e8
method,gputime,cputime,occupancy,global_store_transaction
_Z12kernel_writePjj,7807.584,7831.000,1.000,557058
Here gst_request and global_store_transactions are exactly the same, showing perfect coalescing. Which one is correct (nvprof or the API profiler)? Why does NVIDIA Visual Profiler says that I have non-coalesced writes? There are still significant instruction replays, and I have no idea where they are coming from :(
Any ideas? I don't think this is hardware malfunctioning, since I have two boards on the same machine and both show the same behavior.

Resources