nebgor / sma-bluetooth

Automatically exported from code.google.com/p/sma-bluetooth
0 stars 0 forks source link

segmentation fault when calling smatool not from working dir #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. cd  /mnt/PC-INFO/SMA2/sma-bluetooth ; ./smatool -c SMA2500HF30.conf
succeeds

2. cd /home/user ; cp /mnt/PC-INFO/SMA2/sma-bluetooth/SMA2500HF30.conf
 /home/user/ ; ./smatool -c /home/user/SMA2500HF30.conf

3. cd /home/user ; /mnt/PC-INFO/SMA2/sma-bluetooth/smatool -v -c 
/mnt/PC-INFO/SMA2/sma-bluetooth/SMA2500HF30.conf
Segmentation fault

4. cd /home/user ; cp /mnt/PC-INFO/SMA2/sma-bluetooth/SMA2500HF30.conf
 . ; /mnt/PC-INFO/SMA2/sma-bluetooth/smatool -v -d -c SMA2500HF30.conf
variable=Inverter value=3000TLHF
variable=BTAddress value=00:80:25:1E:C7:D1
variable=BTTimeout value=
variable=Password value=0000
variable=Config value=
variable=File value=sma.in.new
variable=Latitude value=
variable=Longitude value=
variable=MySqlHost value=localhost
variable=MySqlDatabase value=smatool
variable=MySqlUser value=
variable=MySqlPwd value=
variable=PVOutputURL value=http://pvoutput.org/service/r1/addstatus.jsp
variable=PVOutputKey value=
variable=PVOutputSid value=
Segmentation fault

What is the expected output? What do you see instead?
smatool should be callable from any working directory. 
Instead I get a 'Segmentation fault' when my working directory is not equal to 
the directory where smatool resides.

What version of the product are you using? On what operating system?
smatool-0.14
Gentoo Linux 2.6.39-gentoo-r3 

Please provide any additional information below.
From the strace, I see the reason is that smatool doesn't find sma.in.new.

As a solution I propose:
1. in the program catch the error to exit gracefully 'Could not find 
/{dir-where-smatool-is-looking}sma.in.new'
2. in the default config file, document that the path to smatool should be 
either a full path (or relative to the location of smatool)
3. A more intuitive solution is to make sma.in.new relative to the conf file

Original issue reported on code.google.com by vereecke...@gmail.com on 23 Nov 2011 at 10:47

Attachments: