Need further explanation on ESP8266 SDWebServer example code - webserver

I'm trying to understand the ESP web server from SD card, by the example code. And I simply don't see how the server respond to "/" request, since in other server examples usually there is a server.on("/", WhateverFunction); line, but not on this example.
Whats calling the loadFromSdCard function? What would be the simplest way to open a file from SD card? Or a simply line by line explanation on whats happening on would be appreciated too

Related

pymodbus USB connection issue

I have a Click PLC that I am trying to read coil data from. I am using pymodbus, but I am getting a connection error. The only issue I can come up with is that I don't know if the port entry is correct. I am using an RS-232 converter to USB. The USB is on com4. This there a reason I can't get a connection. Simple code is below.
Thanks,
Marc
from pymodbus.client.sync import ModbusSerialClient
click = ModbusSerialClient(method='rtu',port='com4',baudrate=9600,parity='O')
outputLight = click.read_coils(8193,1,unit=1)
print outputLight
You're missing something like:
click.connect()
After defining your connection and before reading coils.
As you say it seems some of your settings are not correct, maybe you can try something like QModMaster (I'm assuming you're on Windows). It will be easier to try different settings and ports faster, just to make sure you have the correct port at least. See here: https://sourceforge.net/projects/qmodmaster/

Why don't serial ports work properly in Unity?

I need help, I'm desperate
During two weeks I have been working in my project, this uses serial port communication (a PIC serial board). I got to set the connection up, but I can not get data from the COM port. I've read some forums and the cause of the problem seems to be the incomplete implementation of System.IO.Ports class.
When I try to get data of the COM port, the event SerialDataReceivedEventHandler (represents the method that will handle the DataReceived event of a SerialPort object.) is not called or activated. I tried to resolve it but I don't find a definitive solution. I thought to prove a external DLL, but a friend told me that the problem will go on, in fact I did it and got the same problem: SerialDataReceivedEventHandler does not work. Also, someone recommended me using a secondary thread, although I don´t understand how to do it at all.
I wrote a program in visual C# and everything works fine. I'm intrigued.
I need to find a solution, some idea or good documentation. If there's someone knows something about it, help me please.
I need to understand the cause of this to continue.
Unity is based on Mono, and Mono doesn't implement completely the Serial class, in particular there are no notifications implemented (such as SerialDataReceivedEvent).
That's why it works in Visual Studio, and not in Unity.
Here are the differences between the Mono and complete .NET implementation of the Serial class :
Extract from http://www.mono-project.com/archived/howtosystemioports/#limitations
"Limitations
At the time of this writing, there are a a few limitations that one must take note:
1) There is no event notification for received serial data. If you want to receive data, one must set a timeout and watch for received data by polling ReadByte() when you think there might be data.
2) One must Read data in byte[] format only – there is no char[] support. You must do your own reading of bytes and translate that into your encoding.
3) DiscardNull, ParityReplace, ReceivedBytesThreshold are not implemented."
I think it happens because the Unity is based on Mono instead of .Net, and a pretty old version of it. You couldn't use Linq on iOS devices for a long time because of AOT bugs, and the localisation implementation is buggy (or at least it was in the previous versions of Unity I tried to work with). I wasn't even able to find the source of System.IO.Ports in the source of Unity's Mono fork, so it's surprising it compiles at all.

I2cSlave reading issue on lpc1343

I'm trying to use the lpc1343 as a i2cslave to transmit some data. Writing to the board gives no problems and works exactly as I want it.
However, reading from the board gives problems. It seems I'm not getting any data back although I am sending the right commands. Whenever I try to debug it my board just hangs and I have to reset the driver and my pc to get it running again.
Also, I made a LED go on/off whenever I try to read from it. It only does this once and whenever I try to do it again nothing happens. I think the I2c is stopped then but I have no idea why.
I have found the example code on the website once but now it seems to be gone. Does somebody have an updated I2cslave code?
Which operating system are you writing code for and how can you tell that writing to the i2c chip is successful?
If the write function returns, it could be that the message has been sent but the chip is in a weird configuration that doesn't act on the message received.

asterisk entry point to a SIP dialplan

I understand this should be really easy but I can't find my way around the asterisk configuration files to do this.
What I need in an entry point for a external SIP call to execute an asterisk script. To keep things simple let's say I want to execute something like this:
[my888app]
exten => 888,1,Answer()
exten => 888,2,SayDigits(1234)
exten => 888,3,Hangup
The user will dial this particular 888 SIP extension in the form:
sip:888#mydomain.com
This is not an internal call, the call comes from another server, to test I'm using this Phono sample and the call is getting onto the asterisk server ok, the problem is that I have no idea how to route it to my888app. Already tried /etc/asterisk/sip_general_custom.conf without luck, guess the problem is the context [my888app] is not right. I already have the asterisk CLI in front of me
So, to recap:
No DID funny business, just SIP
In which .conf file do I put the [my888appp]
I dont understand if 888 is an entension or a channel
Multiple calls will be made at the same time to [my888app], is that a
problem?
Right now when I dial from the Phono app I get please enter the
channel number follow by the # sign, I dont know if that is helpful
or not
Thanks!!!
Well, after a lot of searching turns out the routing is as follows (default FreePBX installation):
The SIP calls goes into a context called from-sip-external
from there, it goes to the context from-trunk
from there it goes to from-pstn
from there it goes to ext-did-catchall
And there, in ext-did-catchall, is where I can put my888app and it will execute ok
I'm 100% positive this is not the correct place to put the app, but as I'm not an Asterisk expert I will settle for it.
Hope this help someone else.
Thanks.-
You need check the context attributes in your sip.conf. You can have a context in general section and you can have another in your peer definition, if you dont define any specific context in you peer then the general context attribute is assumed.
For simplicity I advice you change context in general section of sip.conf and put your my888app in extensions.conf.
Example of sip.conf general section:
[general]
context=my888app
...
About 888: it is a extension, an extension is a end point to your call. A channel is a object created dynamically when setting up a call to retain the session information and to exchange data (voice) between two points.
Answer is very simple, Any external call first land on the context which is defined under general section in sip.conf file. There you can define your own dial plan. if you want to redirect to your own context from there then you can use GoSub.

JAVA ME Socket send and receive

I wanted to make an app that when the user press by example (m) on the keyboard the mobile device connects to the server which is made with C# ,and i want it to send a Word and wait for a response , can anybody help me with that because that is my first JAVA ME Application
(i've made a C# Code Client For Testing , if anybody wants to see it so that he can convert it to JAVA ME just comment)
To handle a single key stroke you will need low level graphics with Canvas. Please go through this tutorial http://www.ibm.com/developerworks/java/tutorials/j-j2me2/
keyPressed method will trigger a new connection to your server. See this other tutorial http://www.ibm.com/developerworks/java/library/wi-jio/