Example code not working
Added by Nobels about 8 years ago
Hello,
I am using your messagingtoolkit in my Console project for sending and recieving sms.
Now i have this type of modem: Wavecom Fastrack Xtend FXT009
The code run's on Windows 7 64 bit machine.
The problem is in this piece of code: mobileGateway = messageGateway.Find(config);
This Exception message: is unplugged from COM8. Please connect it again before attempt to disconnect
When i run it again i have an other message: A device attached to the system is not functioning.
Now i don't understand this because in your demo application everything works fine. I can send and recieve messages.
I did the test with your demo before i runned my console project.
Am i missing something here because i compare your code against mine and i don't see any difference.
This is my code:
using System; using MessagingToolkit.Core; using MessagingToolkit.Core.Mobile; using MessagingToolkit.Core.Log; namespace SMSConsoleTestProject { class Program { static void Main(string[] args) { IMobileGateway mobileGateway = MobileGatewayFactory.Default; MobileGatewayConfiguration config = MobileGatewayConfiguration.NewInstance(); config.PortName = "COM08"; config.BaudRate = (PortBaudRate)Enum.Parse(typeof(PortBaudRate), "115200"); config.DataBits = (PortDataBits)Enum.Parse(typeof(PortDataBits), "8"); // Assign a PIN if necessary config.Pin = ""; // Assign a model if you want config.Model = "Wavecom"; config.Parity = PortParity.None; config.StopBits = PortStopBits.One; config.Handshake = PortHandshake.None; // Check for the PIN status during connect config.DisablePinCheck = false; // Default to verbose by default config.LogLevel = LogLevel.Verbose; // Create the gateway for mobile MessageGateway<IMobileGateway, MobileGatewayConfiguration> messageGateway = MessageGateway<IMobileGateway, MobileGatewayConfiguration>.NewInstance(); try { mobileGateway = messageGateway.Find(config); if (mobileGateway == null) { // MessageBox.Show("Error connecting to gateway. Check the log file", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // MessageBox.Show("Connected to gateway successfully", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); Console.WriteLine("Service Center Adress: {0}", mobileGateway.ServiceCentreAddress.Number); Console.WriteLine("Send Retries: {0}", mobileGateway.Configuration.SendRetries); Console.WriteLine("Message Polling interval: {0}", mobileGateway.Configuration.MessagePollingInterval); Console.WriteLine("Send Wait Interval: {0}", mobileGateway.Configuration.SendWaitInterval); Console.WriteLine("Delete Recieved Message: {0}", mobileGateway.Configuration.DeleteReceivedMessage); Console.WriteLine("Logfile: {0}", mobileGateway.LogFile); #endregion } catch (Exception ex) { // MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine(ex.Message); if (mobileGateway != null) { if (mobileGateway.Disconnect()) { mobileGateway = null; mobileGateway = MobileGatewayFactory.Default; } } } } } }
Can you help me out ... thanks
If i get this thing to work i will buy a licence. :-)
Thanks
Replies (11)
RE: Example code not working - Added by Nobels about 8 years ago
Note: I disabled my pincode on the simcard.
RE: Example code not working - Added by admin about 8 years ago
Hi,
I assumed that you run the demo program and your program on Windows 7 64 bits, and the demo works but not the console program?
Have you package all the required DLL with your console program?
See required assemblies here
https://twit88.com/platform/wiki/messagingtoolkit/Wiki_-_Introduction
Thanks
Regards
admin
RE: Example code not working - Added by Nobels about 8 years ago
Hello,
I assumed that you run the demo program and your program on Windows 7 64 bits, and the demo works but not the console program? --> Yes , correct.
Have you package all the required DLL with your console program?
Yes all 4 references are there.
And the properties for all references are set to "_copy local is true_".
Also the platform target is x86
I do not understand what's missing or wrong.
Do you need my project in zipped format ?
regards,
Kris Nobels
RE: Example code not working - Added by admin about 8 years ago
Hi,
Could you attach your project here so that we can have a look?
Thanks
Regards
admin
RE: Example code not working - Added by Nobels about 8 years ago
Sorry for the late response. (Vacation or holiday is the reason)
Now i created 2 projects.
x86 version and 64bit version.
Please take a look.
SMSConsole.rar (4.52 MB) SMSConsole.rar | Demo |
RE: Example code not working - Added by admin about 8 years ago
Hi,
We have no problem running your code.
Are you still receiving this error "This Exception message: is unplugged from COM8. Please connect it again before attempt to disconnect"?
It could be a configuration issue.
In MesssagingToolkit folder, there is a "x64" folder, you could try with those libraries also if you are running under 64 bits environment.
Thanks
Regards
adin
RE: Example code not working - Added by Nobels about 8 years ago
In the project i made i have 2 build versions ...
1 with references to 64 bit dll's and the other is with x86 version dll's.
The strange thing is that it does not work with COM port: COM8.
So i did a test and i stil get the message: Gateway is unplugged from COM8. Please connect it again before attempt to disconnect
After that i start the bulk SMS Gateway sln and connect it to COM8 --> And it's connected with succes :-|
I do not understand what's wrong or missing.
Is there a difference that you can see if the dll is for 64bit or not ?
I create a new demoproject next to the bulk SMS Gateway. See how that goes ...
RE: Example code not working - Added by Nobels almost 8 years ago
Hello,
I found the time to create a small console project (again).
Now i created it from scratch and i have the same problem. :-(
mobileGateway = messageGateway.Find(config); --> is the line where the error occured
these are the properties:
BaudRate = BitsPerSecond115200
DataBits = Eight
Handshake = None
Parity = None
PortName = "COM4"
StopBits = One
All normal to me.
Is it possible to create a small console project in C#
Or can you contact me i would like to call with skype about this problem.
Did you make the test with a wavecom modem ?
regards,
Kris
RE: Example code not working - Added by admin almost 8 years ago
Hi,
Could you attach your program here? or send to [email protected] so that we can investigate?
Thanks
Regards
admin
RE: Example code not working - Added by Nobels almost 8 years ago
Hello,
In the rarfile are 2 solutions
1 GUI app
1 Console app
Both the same problem.
Thanks
SMS_app.rar (1.14 MB) SMS_app.rar |
RE: Example code not working - Added by admin almost 8 years ago
Hi,
We tested with a few modems, and the results are positive. This is most probably a OS related issue.
2011.09.23-09.34.03: Sending: ATZ
2011.09.23-09.34.03: Response: ATZ<cr><lf><cr><lf>OK<cr><lf>
2011.09.23-09.34.03: Found echo in response
2011.09.23-09.34.03: Sending: ATE0
2011.09.23-09.34.03: Response: ATE0<cr><lf><cr><lf>OK<cr><lf>
2011.09.23-09.34.03: Found echo in response
2011.09.23-09.34.03: Sending: AT+CPIN?
2011.09.23-09.34.04: Response: <cr><lf>+CPIN: READY<cr><lf><cr><lf>OK<cr><lf>
2011.09.23-09.34.04: Sending: ATE0
2011.09.23-09.34.04: Response: <cr><lf>OK<cr><lf>
2011.09.23-09.34.04: Sending: AT+COPS=0,2
2011.09.23-09.34.04: Response: <cr><lf>OK<cr><lf>
2011.09.23-09.34.04: Sending: ATE0
2011.09.23-09.34.05: Response: <cr><lf>OK<cr><lf>
2011.09.23-09.34.05: Sending: AT+CMEE=1
2011.09.23-09.34.05: Response: <cr><lf>OK<cr><lf>
2011.09.23-09.34.05: Sending: AT+CPMS?
2011.09.23-09.34.05: Response: <cr><lf>+CPMS: "SM",21,30,"SM",21,30,"SM",21,30<cr><lf><cr><lf>OK<cr><lf>
2011.09.23-09.34.05: Sending: AT+CMGF=0
2011.09.23-09.34.06: Response: <cr><lf>OK<cr><lf>
2011.09.23-09.34.06: Sending: AT+CNMI=0,0,0,0,0
2011.09.23-09.34.06: Response: <cr><lf>OK<cr><lf>
2011.09.23-09.34.06: Ending Async ConnectedEventHandler call
2011.09.23-09.34.06: Sending: AT+CNUM
2011.09.23-09.34.06: Response: <cr><lf>OK<cr><lf>
2011.09.23-04.54.51: Sending: ATZ
2011.09.23-04.54.52: Response: ATZ<cr><lf><cr><lf>OK<cr><lf>
2011.09.23-04.54.52: Found echo in response
2011.09.23-04.54.52: Sending: ATE0
2011.09.23-04.54.52: Response: ATE0<cr><lf><cr><lf>OK<cr><lf>
2011.09.23-04.54.52: Found echo in response
2011.09.23-04.54.52: Sending: AT+CPIN?
2011.09.23-04.54.52: Response: <cr><lf><cr><lf>+CPIN: READY<cr><lf><cr><lf><cr><lf>OK
2011.09.23-04.54.52: Sending: ATE0
2011.09.23-04.54.53: Response: <cr><lf><cr><lf><cr><lf>OK<cr><lf>
2011.09.23-04.54.53: Sending: AT+COPS=0,2
2011.09.23-04.54.53: Response: <cr><lf><cr><lf>OK<cr><lf>
2011.09.23-04.54.53: Sending: ATE0
2011.09.23-04.54.53: Response: <cr><lf><cr><lf>OK<cr><lf>
2011.09.23-04.54.53: Sending: AT+CMEE=1
2011.09.23-04.54.54: Response: <cr><lf><cr><lf>OK<cr><lf>
2011.09.23-04.54.54: Sending: AT+CPMS?
2011.09.23-04.54.54: Response: <cr><lf><cr><lf>+CPMS: "SM",0,30,"SM",0,30,"SM",0,30<cr><lf><cr><lf>OK<cr><lf>
2011.09.23-04.54.54: Sending: AT+CMGF=0
2011.09.23-04.54.54: Response: <cr><lf><cr><lf>OK<cr><lf>
2011.09.23-04.54.54: Sending: AT+CNMI=0,0,0,0,0