Well I got the SMS working from a simple script, so it's onto working on the input and output board, I've ruled out my other option as
I dont have a serial port anymore on the HP microserver, so I thought I'd look at interfacing with the Mega32 using USB.. every option was getting
over complicated and then I stumbled across the CP2102 chip on sparkfun. I was going to order one when I noticed that they were out of stock
quick search on google shopping showed play selling some for £4.18 or so including free delivery! - So I ordered two and they arrived the next day.
Seems to good to be true, anyway I Inserted the USB to TTL convertor and typed dmesg to look at the kernel messages and was presented with:
[6390234.520185] usb 4-3: new full speed USB device using ohci_hcd and address 3
[6390234.731367] USB Serial support registered for cp210x
[6390234.731450] cp210x 4-3:1.0: cp210x converter detected
[6390234.880248] usb 4-3: reset full speed USB device using ohci_hcd and address 3
[6390235.066809] usb 4-3: cp210x converter now attached to ttyUSB2
[6390235.066848] usbcore: registered new interface driver cp210x
[6390235.066854] cp210x: v0.09:Silicon Labs CP210x RS232 serial adaptor driver
Well that was easier than expected, beter than windows that wanted a driver installing..
Now to see if I can talk to my board!...
(15 mins later)
All Working, shocked... now just to write a daemon that will monitor for input on the serial port and do something and also send stuff when requested, now that will take me some doing!
Ill add some pictures next week.
I try to specialise in doing the out of the ordinary stuff (A Challenge!) - And generally making life as easy as possible using any of the technologies within reach without having to re-invent the wheel where possible! Technologies and products can include -> .NET, VBS, Powershell, DSC, Systems Center, NetApp, VMWare, Windows Server, Linux, Python, Microcontrollers and others!
Friday 26 August 2011
Friday 19 August 2011
Update on SMS
Well I was given a 3G dongle which was on the three network, which I managed to unlock using both master unlock Master Unlock and then used the huawei modem code writer tool to flash the device Code Writer I believe these can be written by AT+ commands but I didn't investigate that route. One thing I noticed is that it didn't work on my desktop, I don't know if that's because it's on XP x64 or because the drivers weren't installed - anyway I plugged it into my laptop that has the drivers on for the previous dongle and it was detected fine and unlocked easily :)
I stuck in my old mobile's sim to see if that would work but it seems to have expired and needs topping up or something - anyway that involved effort so I ordered a couple of sims from vodaphone - I get crap reception on vodaphone compared to O2 but I'm informed that they dont expire if you don't top them up, so Ideal for my plans - I managed to order two from here for free Vodaphone so we will see if that works.
Another thing I was looking to build in was alerting around the credit available, I could either do this by counting the number of text's sent but I did stumble across a blog posting here blog which suggests that on vodaphone you can issue the command AT+CUSD=1,"*&1345;",15
which should return +CUSD: 0,"#14.66.",0
Which is your dongle's way of saying £14.66 remaining.
I have yet to try this but I am hopefull that it may work :)
I've also got two new books at work: The bash cookbook and Mastering Unix Shell scripting which may help me out with this process.
I've just been looking more into USB I/O boards though and decide that the
Veleman K8055
Looks a little pricey for what it does and what I want, I've since realised that my WRT job wont quite accomplish what I want due to the lack of a serial port and the fact that I never finished writing the demon that I started but gave up on due to my lack of interest/skills in the C language! Perl just seemed wrong, but I may go back to it!
Quick Update (26/07/2011)
Is that issuing the command to check balance doesnt quite work as said..
sending:
AT+CUSD=1,"*&1345;",15
results in:
OK
Hmm, need to look into this a little more :)
I stuck in my old mobile's sim to see if that would work but it seems to have expired and needs topping up or something - anyway that involved effort so I ordered a couple of sims from vodaphone - I get crap reception on vodaphone compared to O2 but I'm informed that they dont expire if you don't top them up, so Ideal for my plans - I managed to order two from here for free Vodaphone so we will see if that works.
Another thing I was looking to build in was alerting around the credit available, I could either do this by counting the number of text's sent but I did stumble across a blog posting here blog which suggests that on vodaphone you can issue the command AT+CUSD=1,"*&1345;",15
which should return +CUSD: 0,"#14.66.",0
Which is your dongle's way of saying £14.66 remaining.
I have yet to try this but I am hopefull that it may work :)
I've also got two new books at work: The bash cookbook and Mastering Unix Shell scripting which may help me out with this process.
I've just been looking more into USB I/O boards though and decide that the
Veleman K8055
Looks a little pricey for what it does and what I want, I've since realised that my WRT job wont quite accomplish what I want due to the lack of a serial port and the fact that I never finished writing the demon that I started but gave up on due to my lack of interest/skills in the C language! Perl just seemed wrong, but I may go back to it!
Quick Update (26/07/2011)
Is that issuing the command to check balance doesnt quite work as said..
sending:
AT+CUSD=1,"*&1345;",15
results in:
OK
Hmm, need to look into this a little more :)
Thursday 11 August 2011
SMS from Linux
It has to be said that I'm pretty tight when it comes to parting with cash, I was wanting my home alarm and cctv to be able to text me - I started looking at GSM based diallers but they are stupid money. So I though the easier way would be to interface with the PC.
I already have a network based IO board I erm fashioned out of a WRT54G which lets me communicate with inputs and outputs - so interfacing shouldnt be a problem, however I will probably knock up a USB based IO board given the lack of parrallel ports or anything else on my new HP Microserver and save me having to pass things over the network to the wrt54..
Anyway quick google turns out that a 3G dongle will let me send texts.. hmm :) - Quick look in my laptop bag finds me a Huawei K3765 (Or a white vodaphone 3g dongle to me and you) - It belongs to work but it will do for a quick POC!
Given my linux knowledge is bordering on being a beginner I relied on google and typing commands and hoping for the best as you do, Windows would have been easy but my HP Microserver is running Ubuntu Server 10.10 as it does the simple things I need easier than windows, as much as it pains me to say that!
I shoved the thing in and ran the following:
lsusb
This returned the following:
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 0566:3002 Monterey International Corp.
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0680:0002 Realtek Semiconductor Corp., CPP Div. (Avance Logic) Arowana Optical Wheel Mouse MSOP-01
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 12d1:1465 Huawei Technologies Co., Ltd.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
So at least it could see the device..
running this command:
dmesg | grep -e "modem" -e "tty"
got me this:
[ 0.000000] console [tty0] enabled
Not much there other than the console, so I dont think that found any modems..
Reading between the lines on an another post / link suggested I needed usb_modeswitch, So I ran sudo apt-get install usb-modeswitch-data
Then looking for the device again didnt show much, so I removed it and reinserted it which didnt seem to do too much, or at least I dont think it did!.
I then found another link so blindly pasted the following commands:
rmmod usb-storage
rmmod usb-serial
mknod /dev/ttyUSB0 c 188 0
mknod /dev/ttyUSB1 c 188 1
mknod /dev/ttyUSB2 c 188 2
(there was a modprobe somewhere but dont ask me where! - something like the following: modprobe usbserial vendor=0x12d1)
dmesg | grep -e "modem" -e "tty"
Now got me this:
[ 0.000000] console [tty0] enabled
[5094746.677111] USB Serial support registered for GSM modem (1-port)
[5094746.677229] option 1-3:1.0: GSM modem (1-port) converter detected
[5094746.677409] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB0
[5094746.677447] option 1-3:1.3: GSM modem (1-port) converter detected
[5094746.677529] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB1
[5094746.677549] option 1-3:1.4: GSM modem (1-port) converter detected
[5094746.677636] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB2
[5094746.677673] option: v0.7.2:USB Driver for GSM modems
[5094747.213946] option 1-3:1.2: GSM modem (1-port) converter detected
[5094747.214211] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB3
Looking better :)
Now to launch minicom, hmm no.. not installed.. Installed that (I dont think I need to post how)
I ran minicom -s to configure the required terminal settings which were:
Serial Device : /dev/ttyUSB0
Bps/Par/Bits : 115200 8N1
Hardware No
Software Flow Control : Yes
Now when I relaunched minicom I got the following:
Welcome to minicom 2.5
OPTIONS: I18n
Compiled on Feb 5 2011, 06:31:42.
Port /dev/ttyUSB0
Press CTRL-A Z for help on special keys
AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0
OK
Result..
So to send a Text / SMS you need to switch mode..
AT+CMGF=1
then to send a Text / SMS to a number you do..
AT+CMGS=”+44077******” [Enter]
> This is a test Message[Enter]
Cntrl + Z
You should then get
OK
To recieve you can do (un-tested yet)
List SMS
AT+CMGL=”all”
Get individual msg
AT+CMGR=0
Delete message number (n)
AT+CMGD=n
I'll try and make more notes at configuring it when I get a dongle to use permanantley and also ensure that it still works after a reboot, after that it's work out how to make it into something usable for the UPS, Alarm, and CCTV :)
Sad I know, but its kept me out of the pub tonight.
I already have a network based IO board I erm fashioned out of a WRT54G which lets me communicate with inputs and outputs - so interfacing shouldnt be a problem, however I will probably knock up a USB based IO board given the lack of parrallel ports or anything else on my new HP Microserver and save me having to pass things over the network to the wrt54..
Anyway quick google turns out that a 3G dongle will let me send texts.. hmm :) - Quick look in my laptop bag finds me a Huawei K3765 (Or a white vodaphone 3g dongle to me and you) - It belongs to work but it will do for a quick POC!
Given my linux knowledge is bordering on being a beginner I relied on google and typing commands and hoping for the best as you do, Windows would have been easy but my HP Microserver is running Ubuntu Server 10.10 as it does the simple things I need easier than windows, as much as it pains me to say that!
I shoved the thing in and ran the following:
lsusb
This returned the following:
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 0566:3002 Monterey International Corp.
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0680:0002 Realtek Semiconductor Corp., CPP Div. (Avance Logic) Arowana Optical Wheel Mouse MSOP-01
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 12d1:1465 Huawei Technologies Co., Ltd.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
So at least it could see the device..
running this command:
dmesg | grep -e "modem" -e "tty"
got me this:
[ 0.000000] console [tty0] enabled
Not much there other than the console, so I dont think that found any modems..
Reading between the lines on an another post / link suggested I needed usb_modeswitch, So I ran sudo apt-get install usb-modeswitch-data
Then looking for the device again didnt show much, so I removed it and reinserted it which didnt seem to do too much, or at least I dont think it did!.
I then found another link so blindly pasted the following commands:
rmmod usb-storage
rmmod usb-serial
mknod /dev/ttyUSB0 c 188 0
mknod /dev/ttyUSB1 c 188 1
mknod /dev/ttyUSB2 c 188 2
(there was a modprobe somewhere but dont ask me where! - something like the following: modprobe usbserial vendor=0x12d1)
dmesg | grep -e "modem" -e "tty"
Now got me this:
[ 0.000000] console [tty0] enabled
[5094746.677111] USB Serial support registered for GSM modem (1-port)
[5094746.677229] option 1-3:1.0: GSM modem (1-port) converter detected
[5094746.677409] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB0
[5094746.677447] option 1-3:1.3: GSM modem (1-port) converter detected
[5094746.677529] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB1
[5094746.677549] option 1-3:1.4: GSM modem (1-port) converter detected
[5094746.677636] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB2
[5094746.677673] option: v0.7.2:USB Driver for GSM modems
[5094747.213946] option 1-3:1.2: GSM modem (1-port) converter detected
[5094747.214211] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB3
Looking better :)
Now to launch minicom, hmm no.. not installed.. Installed that (I dont think I need to post how)
I ran minicom -s to configure the required terminal settings which were:
Serial Device : /dev/ttyUSB0
Bps/Par/Bits : 115200 8N1
Hardware No
Software Flow Control : Yes
Now when I relaunched minicom I got the following:
Welcome to minicom 2.5
OPTIONS: I18n
Compiled on Feb 5 2011, 06:31:42.
Port /dev/ttyUSB0
Press CTRL-A Z for help on special keys
AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0
OK
Result..
So to send a Text / SMS you need to switch mode..
AT+CMGF=1
then to send a Text / SMS to a number you do..
AT+CMGS=”+44077******” [Enter]
> This is a test Message[Enter]
Cntrl + Z
You should then get
OK
To recieve you can do (un-tested yet)
List SMS
AT+CMGL=”all”
Get individual msg
AT+CMGR=0
Delete message number (n)
AT+CMGD=n
I'll try and make more notes at configuring it when I get a dongle to use permanantley and also ensure that it still works after a reboot, after that it's work out how to make it into something usable for the UPS, Alarm, and CCTV :)
Sad I know, but its kept me out of the pub tonight.
Wednesday 3 August 2011
Quick and Dirty Log Viewing
I've been running some reallocates on some NetApp volumes, however you need to keep checking the syslogs. We send these to our syslog server which archives them daily so we can go back days, weeks and years should we need old logs, I needed a quick way of going through the logs and looking for what I wanted which was any messages related to this task, easy! - Yeah that easy I'll forget, hence this post.
Anyway simple 15 year old MS-DOS will do the first bit... list all the files in the current folder...
for /r in %i in (*) do @echo %i
There, simples a list of the logs.. now to find what I want..
well yeah you can use find but I prefer to use grep and have the gnu tools installed on my windows box here http://www.gnu.org/software/grep/grep.html
so the following should do the trick..
for /r %i in (*) do type %i|grep wafl.reallocate
well it would but it was a bit lacking, quick check of the logs suggests I want wafl.scan too.. Quick google for doing OR with grep (Dont suggest RegEx!) suggest that you use egrep wafl.scan|wafl.reallocate..
hmm check the help... ahh
for /r %i in (*) do type %i|grep -E "wafl.scan|wafl.reallocate"
Done - I think!
Anyway simple 15 year old MS-DOS will do the first bit... list all the files in the current folder...
for /r in %i in (*) do @echo %i
There, simples a list of the logs.. now to find what I want..
well yeah you can use find but I prefer to use grep and have the gnu tools installed on my windows box here http://www.gnu.org/software/grep/grep.html
so the following should do the trick..
for /r %i in (*) do type %i|grep wafl.reallocate
well it would but it was a bit lacking, quick check of the logs suggests I want wafl.scan too.. Quick google for doing OR with grep (Dont suggest RegEx!) suggest that you use egrep wafl.scan|wafl.reallocate..
hmm check the help... ahh
`egrep' means `grep -E'.
for /r %i in (*) do type %i|grep -E "wafl.scan|wafl.reallocate"
Done - I think!
Subscribe to:
Posts (Atom)