Quantcast
Channel: Forum - Recent Threads
Viewing all 5781 articles
Browse latest View live

RE: Enable NetX Socket ADDR_REUSE Flag

$
0
0

Update:  I went away overnight, came back and, without changing anything it started working.  It worked for quite a while, through a number of compiles and changes, none of which were related to the sending of the packet.  Suddenly it stopped working.  Not for love nor money could I make it work, even going so far as to restore the previous nights version from SVN.  Then, like magic, it started working again.  Then it stopped.  Always the same thing: 0x38 on socket connect.  If I launch DockLight I can always connect and get a response - always.

It's gotta be me because everyone else would be screaming about this.  Thoughts?


Enable NetX Socket ADDR_REUSE Flag

$
0
0

Hi,

I am using nx_tcp_client_socket_connect API. I want to set socket address reuse flag, which is possible in linux.

Is there any way to do this?

Because First when i use nx_tcp_client_socket_connect API,it works fine. But if restart the application, it is returning 0x38 value which is not documented in NetX User Manual.

I suspect socket address reuse is the issue.

And why the API is returning 0x38 ??

Please help me !!

Regards,

NaN

RE: Enable NetX Socket ADDR_REUSE Flag

$
0
0

If it helps, here is the majority of the code.   LOG() is a message logging routine - mostly just prints to the debug console.  PEND_CHECK() and UPEND_CHECK are just pended and unpended generic status checkers that will log a message using LOG.  PEND will hang if status is not 0.

  /* Create a socket.  */

   status = nx_tcp_socket_create(&ip_0, &tcpSocket, (CHAR *) "Echo Server Socket",

                                 NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 512, NX_NULL, NX_NULL);

   PEND_CHECK(status, "Socket Create");

   /* Bind the port to the TCP socket  */

   status =  nx_tcp_client_socket_bind(&tcpSocket, CLIENT_SOCKET, NX_WAIT_FOREVER);

   PEND_CHECK(status, "Socket Bind");

   LOG(MESSAGE_PRIORITY_MEDIUM, "Trying socket disconnect first...");

   status = nx_tcp_socket_disconnect(&tcpSocket, 400);

   UPEND_CHECK(status, "Socket Disconnect");

   LOG(MESSAGE_PRIORITY_MEDIUM, "Setting up Receive Notify");

   status = nx_tcp_socket_receive_notify(&tcpSocket, tcpDataReceived);

   UPEND_CHECK(status, "Receive Notify");

   /* Loop to create and establish server connections.  */

   while(1)

   {

       status =  nx_tcp_client_socket_connect(&tcpSocket, HOST_IP_ADDRESS, HOST_SOCKET, NX_WAIT_FOREVER);

       //        status =  nx_tcp_client_socket_connect(&tcpSocket, HOST_IP_ADDRESS, HOST_SOCKET, 1000);

       UPEND_CHECK(status, "Socket Connect");

       /* Allocate a packet.  */

       LOG(MESSAGE_PRIORITY_MEDIUM,"Allocating Tx Packet");

       status =  nx_packet_allocate(&pool_0, &txPacketPtr, NX_TCP_PACKET, NX_WAIT_FOREVER);

       /* Check for error.  */

       UPEND_CHECK(status, "Allocate TX Packet");

       /* Place "Hello_and_Goodbye" in the packet. */

       LOG(MESSAGE_PRIORITY_MEDIUM,"Filling packet with data");

       UCHAR fakeData[13] = {13,0xfB,0xff,0xff,0x07,0,0,1,123,00,29,01,15};

       nx_packet_data_append(txPacketPtr, fakeData, 13, &pool_0, NX_WAIT_FOREVER);

       LOG(MESSAGE_PRIORITY_MEDIUM,"Sending packet to host");

       status =  nx_tcp_socket_send(&tcpSocket, txPacketPtr, NX_WAIT_FOREVER);

       /* Determine if the status is valid.  */

       UPEND_CHECK(status, "Send Packet");

       // we need to release the packet if there was an error.  If success, the send routine release it.

       if(status != NX_SUCCESS){

           nx_packet_release(txPacketPtr);

       }

       status = nx_tcp_socket_disconnect(&tcpSocket, 400);

       UPEND_CHECK(status, "Socket Disconnect");

       tx_thread_sleep(1000);

   }

RE: fx_file_open fails to open file

$
0
0

Hi Karol,

yes, in the code I reported, the  FX_FILE g_my_file is decleared external, and it is correctly present in another module.

I looked at the USBX sample code in your link. In my application, at the startup I can successful open the file, read and close it without any problem. The problem come out when I try to open again the file already created calling the fx_file_open function.

Is it mandatory to decleare the FX_FILE g_my_file static?

RE: fx_file_open fails to open file

$
0
0

Hello Laser,

If you created a file, written to it and closed it, then you should try using fx_media_flush to make sure that all buffers are flushed and data is actually written to the SD card (I'm not sure how crucial this is for sdmmc, but it's quite important for USB, for example). As for static storage type - if your FX_FILE structure is declared outside of function scope, then it will be allocated somewhat statically anyway (however the symbol emitted will be accessible from other files). The main problem would be when FX_FILE is created inside the function as it would no longer be valid once that function returns.

Also, make sure you're not calling fx_media_close before opening the file again as this unmounts the media and you won't be able to access it until it's mounted again.

Regards

RE: fx_file_open fails to open file

$
0
0

Hi Karol,

thank you, the problem was that I call the fx_media_close and then try to open the file again.

Now, the second time I open the file to modify it, no error occours. But when I try to open that file at the following boot, the last modifications seem to be not retained.

My sequence is:

[Startup]

  1. fx_file_open (for read)
  2. fx_file_read
  3. save file content in RAM
  4. fx_file_close

After that, when I need to change (write) that file:

  1. fx_file_open (for write)
  2. fx_file_write
  3. fx_file_close
  4. fx_media_flush

Are there something wrong inside the procedure?

Thank you

RE: fx_file_open fails to open file

$
0
0

Hello Laser,

In one of the posts above I can see that you enabled "format media during initialization", hence your data is not retained after rebooting the board.

Regards

RE: fx_file_open fails to open file

$
0
0

Yes, I had already change that option to "disabled", so I don't format the media now.

When have I to call the fx_media_flush? Every time I write onto it or just before closing the media?

It seems I cannot write into the file (altough the function return success). Any other idea please? Does the file name matters?

Here my configuration:


RE: fx_file_open fails to open file

$
0
0

Hello Laser,

You should call flush after writing the data and closing the file, and also before unmounting the media or shutting down the device.

Regards

RE: Enable NetX Socket ADDR_REUSE Flag

$
0
0

More information:  This application is a replacement for an existing controller that we have 1500 of deployed and working.  They all work this same exact way - open the socket, send one packet (as seen in the code above) wait for a single response, close the socket, repeat.  System is RL78 running uIP.  I have four of them sitting next to this system, on the same switch, same LAN, same gateway, and they all work fine.

Again, it's gotta be me somehow, but I just don't see it.  I've wiresharked it, etc.  Sometimes it works, sometimes it doesn't.  Mostly it doesn't.  Just lots of "TCP Port Numbers Reused".

The packet goes out, often it gets retransmitted almost immediately, nothing comes back.  I connect to the internal server (not same system - just a python script listening on a socket and echoing whatever it hears) and it works perfectly.  

We can say it's a server issue, but if I can talk to it with other stuff but not with this, there's a problem...

RE: Enable NetX Socket ADDR_REUSE Flag

$
0
0

I think I found it... I'll let you know.

RE: GUIX template windows

$
0
0

Hello Lucas,

GUIX Studio template windows gather window and its children under single instance that can be easily duplicated. The event handler for each template window is different (just as it would be for a widget), however you only get access to one event handling function for all widgets (inside and outside of the template). What you can do in your application, is create an event handler-like function that would call first inside actual event handler for each individual window. This function would handle events from widgets inside temple (you can use GX_SIGNAL(widget_id, event_id) to receive child events at the parent level). Once it returns, the actual event handler would perform window-specific tasks.

There are also other ways of getting the functionality you described. If all you require is to place some header/footer overlay on the window, you can use custom drawing function that would first call the default drawing function (gx_event_draw(p_window)) and then perform canvas drawing using gx_context_* and gx_canvas_* functions.

Alternatively, you can also create nested windows. Your top-level window will contain header and footer and act as a parent for other windows. In case when you need to change between windows, you can simple detach/attach windows to the top-level window, rather than root window.

Regards

RE: GUIX template windows

$
0
0

Thank you Karol for your reply.

I'll try those alternatives you sugested and see what fits better in my application.

Regards,

Lucas

GUIX template windows

$
0
0

Hello everybody,

I'm developing an application that has the same header and footer in every window. I'd like to know how to use a template window properly, and how to setup two event handlers in the same window (one to handle the template widgets and the other to handle the widgets in that particular screen). Is there any example I can download to use as a guideline?

Thanks in advance,

Lucas

RE: fx_file_open fails to open file

$
0
0

Hi Karol,

sorry, but I still can't understand why in my application I am able to write one time after the creation of a file, and then I can't write on it anymore.

Is there any reason why I can write only one time on a file? I was looking for some kind of "writing protection" on the configurator, but I couldn't find anything..

Thank you.


RE: fx_file_open fails to open file

$
0
0

Hello Laser,

By default, after opening the file, the read/write pointer is set to the start of the file, meaning you'll overwrite anything that's inside the file so far. You can place the pointer at the end by calling fx_file_relative_seek(p_file, 0, FX_SEEK_END);.

Regards

RE: fx_file_open fails to open file

$
0
0

Hi Karol,

for me is ok to overwrite the whole file, so I don't need to add records at the end.

Is it correct to close the file and flush the media at every reading or writing operation on that file?

RE: fx_file_open fails to open file

$
0
0

Hello Laser,

You don't need to flush media after reading, it is only required after writing data. It think your transfer/sdmmc driver may be misconfigured, can you paste your setup? Also, when using channel 1 (eMMC on PE-HMI1), you will also need to enable ACCS interrupt for channel 0, as there's a typo in the code.

Regards

RE: fx_file_open fails to open file

$
0
0

Karol,

I am using the channel 0, my interrupts settings are:

My configuration is:

The situation is the following:

  • I create the file:

status = fx_file_create(&g_fx_media0, (CHAR *)nomeFile);

  • Write something on the file.dat (I tryied with a struct, a string, ecc..):

status = fx_file_open(&g_fx_media0, &g_my_file, (CHAR *)nomeFile, FX_OPEN_FOR_WRITE);

status = fx_file_write(&g_my_file, &var, sizeof(var));

status = fx_file_close(&g_my_file);

status = fx_media_flush(&g_fx_media0);

"var" is actually written onto the file.
When I read the file, I am able to read correctly the "var" variable. The problem is that I cannot write anymore on the file, even if I call the same routines shown above, which written well the first time).

The reading routines are:

status = fx_file_open(&g_fx_media0, &g_my_file, (CHAR *)nomeFile, FX_OPEN_FOR_READ );

status = fx_file_read(&g_my_file, &var, sizeof(vardascrivere), &tmp);

status = fx_file_close(&g_my_file);

status = fx_media_flush(&g_fx_media0);

RE: Playing Sound with S3

$
0
0

Hello Pascal,

No Synergy device has an on-chip audio decoder, however that shouldn't stop it from playing sounds as you can either handle raw PCM data or implement software decoder. Let me discuss first case in more detail:

- For playing audio, I highly recommend using sf_audio_playback Framework.

- It's supported by one of two hardware layers: sf_audio_playback_hw_dac or sf_audio_playback_hw_i2s.

- I2S framework uses our SSI hardware to output digital bitstream to the I2S-compatible DAC. You can find one on the DK-S3 board. Other kits do not have on-board I2S DAC but SSI is supported by all S3, S5 and S7 devices.

- DAC framework uses 12-bit DAC with DTC/DMA input on a timer (GPT/AGT) trigger.

We have few audio playback examples, among which you'll find a complex GUIX Audio Player application, but also Simple Audio Playback example for DK-S1: www.renesas.com/.../D3018040.html

Looking through this example will help you understand the way audio playback operates. Essentially, it manages transfer driver to send audio samples at desired sampling rate to the DAC. It provides software scaling for volume control on top of that. Input audio data must be in unsigned 16bit mono PCM format. GUIX Audio Player reads WAVE header and skips past it, while the DK-S1 example operates on raw audio stream. You can extract your own raw audio data using Audacity (saving as RAW) and then converting it to C array (using bin2h or HxD). Alternatively, you can create a simple sine array using arm_sin_q15 CMSIS function (remember to change the sign bit).

To answer your other questions, you can play sound stored in flash with a zero CPU/RAM load by configuring a transfer driver to do repeated transfers into the DAC on periodic timer trigger (similarly to what audio playback framework does). P0_14 is a pin for DAC0 output which is usually connected to the on-board headphone amplifier and then to the headphone jack.

Regards

Viewing all 5781 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>